Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I have an AngularJS app running from a Site that and the main page and partial pages are all wrapped in an apex:page with these attributes:

<apex:page showHeader="false" sidebar="false"
        standardStylesheets="false" applyHtmlTag="false">
     // AngularJS content
</apex:page>

I'd like to know if it is possible to eliminate this automatically generated content from the output:

<script src="/faces/a4j/g/3_3_3.Finalorg.ajax4jsf.javascript.AjaxScript?rel=1398024554000"
        type="text/javascript"></script>
<script src="/eep/static/111213/js/perf/stub.js"></script>

as it serves no useful purpose.

Do any of the apex:page attributes that I am not setting have the effect of removing these script references?

PS

See this answer for some (safe harbored) Salesforce plans about this.

share|improve this question
    
They probably are to track VF statistics, possibly related: salesforce.stackexchange.com/a/2148/119 –  Samuel De Rycke Apr 23 at 11:44
    
Thanks @SamuelDeRycke. The stubs.js I get is only about 1K/2K (depending on which size figure you take from Chrome's developer tools) so if it has to stay so be it. But the AjaxScript is 18K/70K which is quite a lot to download and execute for no reason. –  Keith C Apr 23 at 11:51
    
Don't lose any sleep over it @KeithC - it's a web application, not a mobile landing page :-) –  bigassforce Apr 23 at 13:11
    
User320...he said it was a site. I have the same problem, and any site you build these days is mobile for a quarter of your audience. I'd stay up all night if I thought I could get it fixed. –  Shane McLaughlin Apr 24 at 12:36
    
@ShaneMcLaughlin Yeah this was built aiming at "mobile first" as its a customer portal. –  Keith C Apr 24 at 13:04

3 Answers 3

up vote 3 down vote accepted

I had the exact same experience. To my knowledge, it can't be done. I created an idea for it...maybe you could vote for it? Maybe all of you could vote for it. :)

https://success.salesforce.com/ideaView?id=08730000000l2Y8AAI

share|improve this answer
1  
Shane thanks I've added my vote. I'll leave your answer unaccepted for now in the slim hopes there is some solution in the current version of the platform... –  Keith C Apr 23 at 13:14

I've done some digging... The inclusion of AjaxScript is a bug - it should only be included if the VF page contains an <apex:form>. It's fixed in Summer '14 (safe harbor).

stub.js... On the upside, it's only 1289 bytes, but on the downside it's a blocker for putting a mobile web app on VF and having it behave nicely. I'm working on raising the priority of a fix.

share|improve this answer
    
Thanks for posting this and the link. Good to know that the area is getting attention. –  Keith C Apr 25 at 17:46
    
and there was great rejoicing. Yea! –  Shane McLaughlin Apr 25 at 19:29

One way to do this is to write your own template providing function in Angular. The idea here is to do something like this:

  1. generate a service that using the standard $http.get functionality grab the template you want to load.
  2. Utilize a clever regex to strip out VF specific javascript tags from the retrieved html
  3. Hand that html off as the template.

I've got this functioning in an existing org. Let me talk to the owner of the org about open sourcing this bit. We've found a significant decrease in load times for VF templates this way.

share|improve this answer
    
KP so the ng-view come in fat-free, but won't the initial page load will still have the extras items? Why not load the view template from a static resource instead of dealing with vf for them? –  Shane McLaughlin Apr 25 at 13:35
    
@ShaneMcLaughlin Do you have a way to do that? –  Keith C Apr 25 at 13:39
    
@ShaneMcLaughlin well, I have two reasons. 1, it's often much faster to merge {!data} in a vf template and have that served to the app as json, or even just regular merge data like names, etc. than letting Angular make a query, and merge. Doing the initial load lets you do that. 2: The initial load of the vf page -- well, I'm ok with SF tracking the rendering and delivering speed of that. Which is what most of the js does. –  Kevin P Apr 25 at 16:17
    
I put Angular templates in Static Resources (individually, not in a zip). No need for them to be VF pages if you're not using <apex:...> tags, and if you set the media type to text/plain (Angular doesn't care) you can edit them in dev console. They save SUPER fast :-) –  metadaddy Apr 25 at 17:49
    
@metadaddy Makes sense. Do you have a neat way of handling the timestamp part of the static resource URL using this approach? –  Keith C Apr 28 at 15:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.