Add option to Visualforce to not inject scripts when using no SF code - Ideas - Salesforce Trailblazer Community
Trailblazer Community

All Ideas

Idea Details

Post an Idea
This idea has been merged into another idea. To comment or vote on this idea, please visit Option to turn off extra javascript on visualforce pages.
0  Points voting closed
Idea has been posted. Give it an upvote or downvote.

Add option to Visualforce to not inject scripts when using no SF code

Development (Apex, LWC & VF)

# Request
Add a Visualforce option to disable injection of a few <script> tags, perhaps by adding a "dontInjectScript" attribute or by including the desired behavior in another attribute, such as the "applyHtmlTag" attribute.
In particular, these are the script tags which are injected:
- /faces/a4j/g/3_3_3.Finalorg.ajax4jsf.javascript.AjaxScript?rel=1392581006000
- /static/111213/js/perf/stub.js 
# Reason
The HTML templates that our app use are stored as Visualforce pages. This is nice because we can use VF components like <apex:repeat> and use Apex controllers. These templates are secretly injected with <script> tags. While not malicious, we don't need them and they are severely slowing our app. I looked through the Salesforce docs, and I see no options for this.
<apex:page showHeader="false" 
applyHtmlTag="false"> <!-- When 'true', this should disable script injection. -->

As you can see, we have suppressed as many SF-injected scripts and styles as we can, but those two are still being added.
# Context:

We are writing a JavaScript application which has a nav-bar to choose different views onto a specified object. When we click on a nav-bar item, the app fetches the new view's HTML template, fetches its data, and then puts it on the page.

Later, we refactored our JavaScript app. We moved our templates to Visualforce pages, and requested them through the REST api from our JS code. After refactoring, our app got terribly slow. I was pretty devastated. A JavaScript app should be snappy! Not slow! What's causing this problem?

I profiled the app to discover what was causing this severe performance bottleneck, and I discovered that the HTML templates we request from Visualforce have been injected with <script> tags in the page's <head>. When these templates are added to the page, the browser sees these script tags and stops adding the template until the referenced scripts have been fetched. This can take 200+ms per script. Way too high.

I'm pretty sure these tags aren't useful to us, so I set up my browser to block them. With them blocked, I used the app again, and I saw that its performance shot up, almost as fast as any other JavaScript app. Very nice!
Now, how do we remove them for *all* users of our app, not just those with a customized browser? I have added a workaround to our app - custom code to strip these <script> tags, but a better solution is to not inject them in the first place.

· Flag

  • Upvotes
  • Downvotes



from AppExchange


No results found.

Help us to keep IdeaExchange clean by pointing out overlapping ideas. We'll investigate your suggestion and merge the ideas if it makes sense.



Thanks for your merge suggestion. We will review it shortly and merge the ideas if applicable.

Salesforce takes abuse situations very seriously. Examples of abuse include but are not limited to posting of offensive language or fraudulent statements. To help us process your request as quickly as possible, please fill out the form below describing the situation. For privacy and security reasons, the final outcome of an abuse case may not be revealed to the person who reported it.


Thank you for your feedback. We take abuse seriously and will investigate this issue and take appropriate action.