"Sync" load with non AMD/Common scripts

38 views
Skip to first unread message

Mathieu ROBIN

unread,
Jan 27, 2014, 8:00:40 AM1/27/14
to cuj...@googlegroups.com
Hi everybody !

I meet a problem and hope to find a solution. In the company for the which I work, we have inherited a lot of scripts to maintain from a very long history in the company (near 10 years). My problem is there. I speak about hundreds of files with a lot of dependencies and hundreds lines each one. No tests of any sort.

To load dependencies, the previous developers used the jquery.getscript method (http://api.jquery.com/jquery.getscript/). Which doesn't allow to have the ability to debug scripts in a devtools except by reloading again and again with a lot of console.log :s
Every module load needs callbacks to chain correctly dependencies.

How to synchronously load scripts without transforming each one in common/amd modules ? I tried to use curl, require and a few of others, I have written a comparing tool (http://mathrobin.github.io/js_loaders/#/) to maybe find a tool which can do this but didn't find the solution...

Have you an idea ?

Thanks everyone in advance, hope you will have a solution :s

PS: sorry for my english

unscriptable

unread,
Jan 29, 2014, 10:42:02 AM1/29/14
to cuj...@googlegroups.com
Hello Mathieu!

Sorry about your hundreds of non-modular files. :(  Hopefully, we can help a bit. :)

curl.js has a utility for loading non-modular scripts.  It is the curl/loader/legacy module.  It works great.  However, if you're new to modules, then you might need some advice to set it up for hundreds of files!  

You say you need to load these modules sync, but I doubt that's strictly necessary.  I'll bet you could find a way to configure curl.js to load the scripts in the right order.  Of course, this job would be much easier if you could concatenate the hundreds of files into a smaller number of files.  Do you think that's possible?

If you are planning to migrate your code base to modules, then curl/loader/legacy might be a good way to start.  If you are not planning to move to modules, I suggest you look at LABjs.

If you think that you want to move your codebase to modules (even if it's very slowly), then let us know. :)

-- John

P.S. your English is fine!
Reply all
Reply to author
Forward
0 new messages