30
JS, CMS, UNTANGLE THE MESS Chris Ward @chrischinch

JS, CMS, untangle the mess

Embed Size (px)

DESCRIPTION

My MelbJS Feb 2014 talk on how CMSs (Wordpress, Joomla, Drupal and Expression Engine) use JavaScript.

Citation preview

Page 1: JS, CMS, untangle the mess

JS, CMS, UNTANGLE THE MESSChris Ward

@chrischinch

Page 2: JS, CMS, untangle the mess

DISCLAIMERS

I’m more of a PHP guy

My JS use is fairly ‘traditional’

See, i’m even using Keynote!

Page 3: JS, CMS, untangle the mess

WHY USE A CMS?

• Ideal for a particular job

• Existing systems

• Familiarity

Page 4: JS, CMS, untangle the mess
Page 5: JS, CMS, untangle the mess

THE PROBLEMS

• Conflicts

• Page weight

• Non specificity

Page 6: JS, CMS, untangle the mess

WHAT’S AVAILABLELots…

Page 7: JS, CMS, untangle the mess
Page 8: JS, CMS, untangle the mess

WE WILL FOCUS ON

• Drupal

• Wordpress

• Joomla!

• Expression Engine

Page 9: JS, CMS, untangle the mess
Page 10: JS, CMS, untangle the mess

DRUPAL JS OVERVIEW

• Started with ‘generic’, settled on JQuery

• Currently D7 ships with JQuery 1.4.2 / UI 1.8

• Can easily (and often is) upgraded to latest

• Used for UI enhancements, ajax DOM manipulation etc…

• All js is aggregated (if turned on)

Page 11: JS, CMS, untangle the mess

OTHER OPTIONS

Umpteen UI modules (carousels, selectors, Modals), JSON processing, Dynamic forms, Responsive, Masonry, Modernizr, AngularJS, Backbone, NodeJS and many many more…

Page 12: JS, CMS, untangle the mess

ADDING JS

drupal_add_js() - The path to your js code + some parameters.

These allow to pass settings, how JS is to be rendered, where/when it’s to be loaded

Four sets of arrays can be passed -

var Drupal = Drupal || { 'settings': {},

'behaviors': {}, 'themes': {}, 'locale': {} };

Page 13: JS, CMS, untangle the mess

MORE INFORMATION

drupal.org/node/121997

Page 14: JS, CMS, untangle the mess
Page 15: JS, CMS, untangle the mess

WORDPRESS JS OVERVIEW

• Currently ships with JQuery 1.11, Backbone, TinyMCE and a few other scripts

• Can easily be upgraded to latest

• Used for UI enhancements, ajax DOM manipulation etc…

• Can be aggregated through plugins

Page 16: JS, CMS, untangle the mess

ADDING JS

wp_register_script( $name, $url,

$dependencies, $version,

$load_in_footer );

wp_enqueue_script()

wp_dequeue_script()

wp_localize_script()

Page 17: JS, CMS, untangle the mess

OTHER OPTIONS

Umpteen UI modules (carousels, selectors, Modals), JSON processing, Dynamic forms, Responsive, Masonry, Modernizr, AngularJS, Backbone, NodeJS and many many more…

Page 18: JS, CMS, untangle the mess

MORE INFORMATION

codex.wordpress.org/Using_Javascript

Page 19: JS, CMS, untangle the mess
Page 20: JS, CMS, untangle the mess

JOOMLA! JS OVERVIEW

• Currently ships with JQuery 1.81, Bootstrap, JQuery UI 1.8.23 and Mootools/Joomla JS

• Can easily be upgraded to latest

• Used for UI enhancements, ajax DOM manipulation etc…

• Can be aggregated through plugins

Page 21: JS, CMS, untangle the mess

ADDING JS

$document =

JFactory::getDocument();

$document->addScript(‘script');

JHTML::script('sample.js',

'templates/custom/js/');

Page 22: JS, CMS, untangle the mess

OTHER OPTIONS

Umpteen UI modules (carousels, selectors, Modals), JSON processing, Dynamic forms, Responsive, Masonry, Modernizr,* AngularJS*, Backbone, NodeJS and many many more…

Page 23: JS, CMS, untangle the mess

MORE INFORMATION

docs.joomla.org/Adding_JavaScript

Page 24: JS, CMS, untangle the mess
Page 25: JS, CMS, untangle the mess

EXPRESSION ENGINE JS OVERVIEW

• JQuery v1.6.2?

• Can’t be upgraded

• Used for UI enhancements, ajax DOM manipulation etc…

• Assume it has JS aggregation

Page 26: JS, CMS, untangle the mess

ADDING JS

{exp:jquery:script_tag}

plugin=

ui=

effect=

file=

ee()->cp->add_js_script(array('plugin' =>

'dataTables'));

ee()->javascript->output();

ee()->javascript->compile();

Page 27: JS, CMS, untangle the mess

OTHER OPTIONS

Hmm…

Page 29: JS, CMS, untangle the mess

SUMMARYEach CMS handles and utilises JS in it’s specialised

way.

Page 30: JS, CMS, untangle the mess

THANKS!Chris Ward

@chrischinchchrischinchilla.com