/    Sign up×
Community /Pin to ProfileBookmark

Interesting Article

I thought you guys might be interested in this new article over on WebReference.com.

[B]How to Auto Include a JavaScript File[/B]
[I]By Mark Kahn[/I]

Many developers have a large library of JavaScript code at their fingertips that they developed, their collegues developed, or that they’ve pieced together from scripts all over the Internet. Have you ever thought that it would be nice to not have to search through all those files just to find that one function? This article will show you how to dynamically include any JavaScript file, at runtime, by simply calling a function in that file.

[URL=http://www.webreference.com/programming/javascript/mk/index.html]http://www.webreference.com/programming/javascript/mk/index.html[/URL]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@phpnoviceMar 01.2006 — Yep, definitely interesting! ?
Copy linkTweet thisAlerts:
@UltimaterMar 02.2006 — Wow, never thought of using an XMLHttpRequest on a JS file before to get the source of it. Should help me design more powerful bookmarklets in the future. Very interesting and useful indeed. I personally wouldn't use an XMLHttpRequest to grab the text-source of a function out of a big library for accessibility reasons -- I'd like to see a file full of over 2,000 functions to really make it worth-while to do so which in any case you'd be adviced to simply omit all the unused functions. However if your script DOES indeed use over 2,000 functions at once and will need to call them one-at-a-time as the user triggers them, the method discussed in the article would be helpful to define the functions one-at-a-time, at runtime, as they are needed.
×

Success!

Help @LeeU spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...