Include require.js


Now yo can load your script by commonJS API:

var foo = require('./foo');

Or require it from PHP:


See RequireJS


Phoenix provides underscore.js as a base JS library to help us do more things which native JS cannot do.


Phoenix enabled no conflict mode as default, so you must use underscore instead _:



Phoenix override underscore template syntax to same as Blade and Edge, so we can use double braces to render variables:

underscore.template("hello: {{ name }}").compiled({name: 'World'});

To use template in Blade and Edge, you must add @ before braces to escape the echo tag:

underscore.template("hello: @{{ name }}").compiled({name: 'World'});

See Underscore.js

Underscore String

Support more string operations.


See Underscore.string.js


underscore.string deprecated sprintf() method, so you can use JS sprintf package instead:


See sprintf.js


Phoenix provides backbone.js if you want to build a SPA.


See Backbone.js


Ivia.js is a reactivity MVVM framework for jQuery with Vue-like interface, it can easily work with phoenix scripts and won't break existing DOM events.


See Ivia.js

Simple Uri

Simple Uri is a JS URI object to help us easily handle uri operations in browser environment:


See SimpleUri.js


Silicone is a simple css helper to extend bootstrap and other css frameworks.


See silicone.css

Add CSRF Token

Add CSRF token to <head> as a meta tag

<meta name="csrf-token" content="a7d71a2c21743d8865fdfa61b71b29e8" />

If you found a typo or error, please help us improve this document.