JavaScript Theming, a Paradigm Shift

Share this

Oleg Terenchuk (litwol) is now developing the JavaScript Theming module. The five second elevator spiel: this will move theming from the server to the client.

The longer explanation is a bit more exciting. This module plans to abstract the core of Drupal theming into a javascript layer. This will allow a JSON feed to pass raw data to a browser to be formatted on the fly for display.

The implications are astounding, and I'm still wrapping my brain around the possibilities. For one, it could mean super fast in place load times, because Drupal doesn't have to mess around with passing everything around the theming system. An AJAX request could just ask for the data, Drupal sends it, and jQuery will format your list, table, teaser, or what have you. In its second day of life, it already works with messages (and item lists, I believe).

A potential problem I see might be that slower computers would see slower rendering times. But this is already happening with some jQuery-heavy sites anyway. The benefit would be most seen with faster hardware, but this is always true with cutting-edge technology. Everyone else will catch up soon enough.

In any case, I have a feeling that by this time next year, I'll be blogging about the killer combo that changed the world of Drupal and is sending ripples through the Internet: Embed Widgets + JavaScript Theming...

PS Come to DrupalCampNYC next month to find out more!

Comments

manuee's picture

Give the user the option to choose?

I wouldn't be surprised if slow computers will see their browsers hanged in no time with this approach...

Perhaps a good aproach would be to detect the user's cpu speed (no clue if it is even possible), and fallback to html if below a certain speed.

Another nice feature that would be nice to have, is a "button" to perhaps set a cookie on the user so that he could switch between js or html versions of the webpage.

Just "thinking outloud" here.

It is definetly an interesting aproach, not sure if it is going too far or not, but I will be checking it out for sure!

custom essay's picture

nice!

nice!

TravisC's picture

how about a sproutcore / objective-j integration module?

Kinda interesting, it would be cool to see drupal apps going in this direction
http://www.sproutcore.com/ http://ajaxian.com/archives/an-interview-with-280-north-on-objective-j-a...

From a design standpoint It would pretty neat to build apps in visual interface builder. Sproutcore is heading this direction already. http://developer.apple.com/documentation/DeveloperTools/InterfaceBuilder...

for these kind of apps SEO really isn't necessary.

Oleg Terenchuk's picture

Interface building is already

Interface building is already possible: http://drupal.org/project/atck

besides the benefits this technology brings (ajax stuff), we have to remain on our toes not to overload the system, because for example the sproutcore system is painfuly slow.

Nick Sergeant's picture

Agreed - I think we'll all

Agreed - I think we'll all enjoy the day Google decides to begin crawling dynamically generated content. :)

Nick Sergeant's picture

SEO?

What about the potential implications generating content via AJAX has on SEO? Many search engines are still not efficiently crawling JavaScript generated content.

aaron's picture

Hijax

Good question. I believe it would be crucial (as always) to continue to support HTML in addition to AJAX, just as we make an effort to support older browsers. Hijax: Progressive Enhancement with Ajax gives a good synopsis of the reasons and some techniques for doing this. I think that as long as we approach this idea carefully, and keep in tune with the industry, we'll be okay. For instance, Google blogged about keeping AJAX SEO friendly last fall.

The nice thing about abstracting this into a module is that it gives us a central location for AJAX theming, that will hopefully be extensible enough to plug into, and will ensure our sites are conforming to a standard that is supported both by client browsers and search engine crawlers.

aaron's picture

Markup Irrelevant?

Additionally, at least theoretically, with Google and most of the others, the markup of content is not such a concern, and can even get in the way of crawling. So in some sense, providing raw data for the search engines might not be a bad idea.

yaph's picture

The markup of content is an

The markup of content is an important concern for search engines. Titles and headings have a higher weight than text in a paragraph.

aaron's picture

Fall back to HTML

This is true. Which is why we'd probably need to go the Hijax route. That way two versions of data would be available; the preferred AJAX version that formats on the client side, and the fall back standard HTML way for text readers, when javascript is disabled, or spiders.

Oleg Terenchuk's picture

My battle plan was to offer

My battle plan was to offer API to other modules to display their content in 2 steps:
step 1) this is the first time content is being displayed. this will dump plain HTML from the server to the user
step 2) this will take the content in step 1 and attach actions to it so that when user interacts with that content it will isolate individual sections and communicate it back to the server via AJAX at which point content will be served through JSON + AJAX bypassing module's own theming layers.

the flaw with step 2 is that the module will be limited only to theme functions that are currently defined by js_theming module.
I will take care to come up with with some solution that will enable misc modules expand the javascript theming functionality. the project is still in very early stage of it's life and it already supports item lists, table theme, handles drupal status messages in a smart and admin configured way, allows table themes to offer table sorts just like drupal core does. offers themes for l() and url() functions. i think i forgot to mention other things but as you can see its growing rapidly and pretty soon will include more features to aid user end javascript theming.

The Society for Venturism has chosen me as the recipient of its charity for this year, to hopefully offer me cryonic preservation when the time comes. And this month, Longecity, an excellent forum for the discussion of issues related to extending the lifespan of humans, has offered up a matching grant of up to a thousand dollars to help out! So help out! Please.