Settings

Theme

CommonJS require for the browser in 1k

stuk.github.io

28 points by stu_k 11 years ago · 6 comments

Reader

cj 11 years ago

Here'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

sirodoht 11 years ago

How does it compare to browserify? Is it a drop-in replacement?

  • stu_kOP 11 years ago

    You 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.

lechevalierd3on 11 years ago

Would window.fetch help on saving precious bytes ?

stu_kOP 11 years ago

If anyone has any questions, ask away!

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection