Home > Computers and Internet, JQuery > JQuery Isolation

JQuery Isolation

JQuery

Ever wanted to create a control that could be included on third-party websites? One that smartly loaded up all the JavaScript it needed and execute without any noticeable clashes with JavaScript objects on the third parties web page?

Wanted to do all this and use JQuery as well? Then, as you add those script and CSS tags to their head section programmatically and then include your own JavaScript file that relies on JQuery you find…  runtime errors…

And all because the lady loves milk-tray. No she doesn’t. Well she might. But more to the point your JQuery reliant code must be isolated from the JQuery reliant code on your ‘hosts’ page – as they might use a different version, after all. What a nightmare. How the hell are you going to sort that mess out? Surely somebody who knows the internals of JQuery has taken a look at this, you plead to your coffee mug at 3:25am as you stare out into the darkness of night through the rain covered window…

Thankfully they have. It’s here:

https://github.com/quickredfox/jQuery-Quarantine/blob/master/README.md

I updated it (adding my own extension to the namespace) and including my own CSS and js files along the way. The real clever stuff is the redirection of the callbacks – although, for the most part – if you’re happy to add your inconsequential code to the onload callback in the source file itself, you can ignore the callbacks and the interfaces that go with them completely.

Grab the source and start updating – the A-Team in me says: Works for me! Thankfully a 3 hour bout of depression should free me of such mindless idiocy.

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: