winladen
winladen

Reputation: 69

Prepare script to compile in JavaScript compiler (Google Closure)

I have code written in many places. I want to refactor the code to be able to use JavaScript compiler for performance and syntax check reasons. What is the recommendation to prepare the code for compiling?

Code:

<% if(product.type){ %>
        $('#someid').html('<%= product.type %>');   //javascript
<% } %>

I've heard that writing in closure style helps variable collision between each script files. Do I have to rewrite all code using that pattern? Do I have to construct the code from scatch? I'm asking for the way to prepare the code to be compiled, any suggestion?

Upvotes: 1

Views: 110

Answers (1)

epascarello
epascarello

Reputation: 207501

The compiler does not change global and property names. It just renames the local variables and removes the whitespace.

Upvotes: 0

Related Questions