4 ms·
CommonJS require for the browser in 1k
- stu_k 12y agoIf anyone has any questions, ask away!
- sirodoht 12y agoHow does it compare to browserify? Is it a drop-in replacement?
- stu_k 12y agoYou run Browserify to bundle your modules offline, and then embed that bundle. With require1k you just embed the script and use one of the API methods to load your main module and everything is downloaded as needed. They are two different approaches. require1k has a limited feature set (due to its size), creates a lot of http requests and is really suited for a small prototyping where you don't want to set up Browserify's build process. Browserify is what you should actually be using for production sites.
- lobster_johnson 12y agoI just plop Browserify into a project's routes (eg., using browserify-middleware [1]), and have everything automatically build when the browser requests it. With this [2], you get fast incremental builds. [1] https://github.com/ForbesLindesay/browserify-middleware https://github.com/ForbesLindesay/browserify-middleware [2] https://github.com/bjoerge/rebundler https://github.com/bjoerge/rebundler
- lechevalierd3on 12y agoWould window.fetch help on saving precious bytes ?
- cj 12y agoHere's a simple implementation in 20 lines of code - I use this in production for our single page Backbone app (migrated away from Requirejs). https://gist.github.com/paton/ab27a1be7e843d220ee3 https://gist.github.com/paton/ab27a1be7e843d220ee3