function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ricardcabreraricardcabrera 

External javascript files using Expressions

Hi,

 

We're trying to optimize the use of javascript and visualforce pages and we decided to move all the code to different javascript files. The problem is, if I have something like this:

 


   alert('{!$ObjectType.Custom_Object__c.Name}');

   

 

This is just an example, where I'm printing the name of an SObject

 

The problem is with the expression between {! }. If we store this code in a .js file and we put it in a Static Resource the expression is never being compiled. Is there a way to organize our code without having to hardcode all the javascript code in the VisualForce pages?

 

Thanks! :)

 

JitendraJitendra

Hi Recard,

Instead of using expressions inside external JS file, it would be recommended to use the arguments in methods instead.