Jump to content


The Phantom

Recommended Posts

How would I re-write this to be more secure? Someone told me this line is now secure.


echo'<script>!window.jQuery && document.write(\'<script src="http://code.jquery.com/jquery-1.4.2.min.js"><\/script>\');</script>';



No worries :)

Edited by The Phantom
Link to comment
Share on other sites

( for others ) No it's a method of a fallback when loading jQuery.

The idea is, load jQuery via some form of CDN ( Google's for example ), then include a variation of the above to load a local copy ( or another CDN if you wish ) in case of failure.

<script src="//[insert cdn copy here]"></script>
<script>!window.jQuery || document.write ( '<script src="[local copy here]"><\/script>')</script>

Most commonly found when using this

Relevant snippet

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...