16

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.

6
  • They probably are to track VF statistics, possibly related: salesforce.stackexchange.com/a/2148/119 Apr 23, 2014 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, 2014 at 11:51
  • Don't lose any sleep over it @KeithC - it's a web application, not a mobile landing page :-) Apr 23, 2014 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. Apr 24, 2014 at 12:36
  • @ShaneMcLaughlin Yeah this was built aiming at "mobile first" as its a customer portal.
    – Keith C
    Apr 24, 2014 at 13:04

5 Answers 5

9

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

1
  • 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, 2014 at 13:14
5

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.

2
  • Thanks for posting this and the link. Good to know that the area is getting attention.
    – Keith C
    Apr 25, 2014 at 17:46
  • and there was great rejoicing. Yea! Apr 25, 2014 at 19:29
3

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.

6
  • 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? Apr 25, 2014 at 13:35
  • @ShaneMcLaughlin Do you have a way to do that?
    – Keith C
    Apr 25, 2014 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, 2014 at 16:17
  • 2
    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, 2014 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, 2014 at 15:45
1

Setting apex:page to ContentType="text" gets you clean output. Obviously not very compliant, but works for major browsers.

5
  • 3
    Please read and understand the question and available answers before adding your own. While your answer does something, it is not an answer to the question (that has been resolved by a SF patch anyway) SMH
    – Eric
    Aug 8, 2015 at 12:25
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. Aug 8, 2015 at 23:54
  • 2
    Please note that I did include disclaimer that this is not exactly the right answer. Also it is not clear whether this was resolved. If I have mistaken the question, please elaborate. From current answers it is not clear how to disable them.
    – dzh
    Aug 9, 2015 at 21:35
  • @eric how does the patch work? I am unable to remove standard platform JS in any other way.
    – dzh
    Aug 10, 2015 at 22:19
  • 2
    @MohithShrivastava please use the voting system rather than comments or flags to express your opinion on answers given. Sep 3, 2015 at 8:20
1

try to adding contentType="text/xhtml"

3
  • 2
    Where should this attribute be added? Please add more detail to your answer.
    – Adrian Larson
    Jul 20, 2016 at 12:46
  • 1
    Is this something new to Angular, Visualforce, or HTML5 that was overlooked? You're answering a 2yr old question. Please enlighten us and provide additional details or references as your answer seems incomplete as written.
    – crmprogdev
    Jul 20, 2016 at 12:56
  • <apex:page contentType="text/xhtml">
    – tmdiwakara
    Nov 1, 2016 at 9:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .