SlideShare a Scribd company logo
Progressive Enhancement
with Rails
@tylerjohnst
My Name is Tyler Johnston
What is Progressive Enhancement?
Traditional development with Rails works
great. Full page refreshes, static content,
all HTML generation.

Recommended for you

Assumptions: Check yo'self before you wreck yourself
Assumptions: Check yo'self before you wreck yourselfAssumptions: Check yo'self before you wreck yourself
Assumptions: Check yo'self before you wreck yourself

Predicting the future is hard and it requires a lot of assumptions, also known as beliefs, also known as faith. In “Assumptions: Check yo self, before you wreck yo self” we explore the consequences of beliefs when constructing predictive models. We’ll walk through the process of developing a demand forecast for Evo, a Seattle-based outdoor recreation retailer, and discuss how assumptions influence the behavior of your application and ultimately the decisions you make.

rsoftware craftsmanshipprice optimization
Introduction to AngularJS For WordPress Developers
Introduction to AngularJS For WordPress DevelopersIntroduction to AngularJS For WordPress Developers
Introduction to AngularJS For WordPress Developers

- AngularJS is a Model-View-Controller framework that can be used to build dynamic single-page applications for WordPress. - It uses bindings to connect views (HTML) to controllers, allowing real-time updates as data changes. Data binding is done through directives like ng-model, ng-repeat, etc. - The $http service provides an easy way to connect Angular models to REST APIs, like the WordPress REST API, to fetch and save data from the backend. This allows building apps that interact with WordPress remotely. - Additional topics covered include using controllers, building reusable components with directives, and ways to customize the WordPress REST API to fit the needs of Angular applications

javascriptwordpressangular
Two Webs! : combining the best of Web 1.0, Web 2.0 and the Semantic Web
Two Webs! : combining the best of Web 1.0, Web 2.0 and the Semantic WebTwo Webs! : combining the best of Web 1.0, Web 2.0 and the Semantic Web
Two Webs! : combining the best of Web 1.0, Web 2.0 and the Semantic Web

The document discusses the differences between the traditional Web and the Semantic Web. The traditional Web links documents together through hyperlinks, while the Semantic Web links data using URIs and RDF. On the Semantic Web, resources are described through multiple representations including graphs of RDF data. Scripting can be used to build applications that retrieve and process Semantic Web data from multiple sources using the HTTP protocol and convert it to and from RDF. This merges the traditional Web and Semantic Web into a single Web.

agents semantic web linked data rdf http html web
But clients and customers want
interactivity and performance.
“Sprinkles of Javascript.”
Keep your Rails workflow but add
Javascript where it’s necessary.
Progressive Enhancment with Rails and React

Recommended for you

ApacheCon 2005
ApacheCon 2005ApacheCon 2005
ApacheCon 2005

The document discusses various methods for consuming web services using PHP, including REST, SOAP, and specific examples using Flickr, Delicious, and eBay APIs. REST uses HTTP requests and XML responses, while SOAP encapsulates requests and responses in XML for platform independence. Examples demonstrate using PHP with SimpleXML to parse REST responses, as well as the SOAP extension to call SOAP APIs and handle authentication.

xmlphpapachecon
Search APIs in Spotlight and Safari
Search APIs in Spotlight and SafariSearch APIs in Spotlight and Safari
Search APIs in Spotlight and Safari

The document discusses three APIs - NSUserActivity, CoreSpotlight, and web markup - that app developers can use to make their app content searchable on iOS devices. It provides details on how to index app data, activities, and web content to improve discovery and bring users into the app via search and Siri suggestions. Best practices are covered such as supporting deep links, using descriptive attributes, and optimizing the app launch experience from search results. Known issues with some search integration features are also mentioned.

Hardcore URL Routing for WordPress - WordCamp Atlanta 2014
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014Hardcore URL Routing for WordPress - WordCamp Atlanta 2014
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014

The document discusses various ways to add custom rewrite rules in WordPress, including: 1) Adding rewrite rules indirectly by registering post types and taxonomies; 2) Adding rewrite tags and rules directly using add_rewrite_tag() and add_rewrite_rule(); 3) Adding endpoints using add_rewrite_endpoint() to route URLs with additional path segments; 4) Adding permastructs using add_permastruct() to define custom URL structures. The document provides examples of validating rewritten URLs, generating custom templates, and serving special templates for rewritten content. It emphasizes the importance of flushing rewrite rules after adding or changing them.

wordpressphprewrite
ails 4 it is now a default gem in the generated G
ert your application in to a single page applica
Download all of the Javascript and
Stylesheets once and reuse for multiple
page views.
s. Turbolinks replaces the content of the <body

Recommended for you

Create responsive websites with Django, REST and AngularJS
Create responsive websites with Django, REST and AngularJSCreate responsive websites with Django, REST and AngularJS
Create responsive websites with Django, REST and AngularJS

The document discusses 10 steps to make a Django site more responsive by adding a REST API and using AngularJS for the front-end: 1) Create an API endpoint for the Django models, 2) Set up the JavaScript environment and install AngularJS, 3) Create a static AngularJS site, 4) Use verbatim tags to avoid conflicts between Django and AngularJS variables, 5) Connect AngularJS to the API, 6) Take advantage of the Django REST Framework features, 7) Handle asynchronous data loading, 8) Add forms and POST requests, 9) Clean up settings.py, and 10) Document the API. The goal is to keep the back-end lightweight Django while building a more responsive and

restdjangoangularjs
An Overview of Models in Django
An Overview of Models in DjangoAn Overview of Models in Django
An Overview of Models in Django

A talk delivered to the Philadelphia Python User Group on 09/17/15 Models form the backbone of most Django sites. They contain the fields and behaviors of the data your site is using. The proper planning and implementation of models is one of the first steps to creating powerful and reusable Django apps. It’s also crucial for avoiding pitfalls and complex workarounds down the line. In this talk you’ll hear about: - • Django model fields and methods • Model inheritance • Relational databases • Migrations • How to access the data stored within your models

web developmentphiladelphia pugphiladelphia python users group
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)

This document provides an overview of hardcore URL routing in WordPress. It discusses how URLs get routed through rewrite rules and patterns, and various functions and hooks in the Rewrite API that can be used to add custom routes. These include registering post types and taxonomies, adding rewrite rules and tags, validating taxonomy terms, and adding endpoints and permastructs. It emphasizes the importance of flushing rewrite rules when making changes.

urlwordpressrewrite
Turbolinks gracefully falls back to
browser defaults for
POST/PUT/DELETE requests as well as
the absence of Javascript.
While Turbolinks provides lots of benefits
there are a few caveats which caused a lot
of developers to not use it.
Turbolinks causes most requests to not
yield a full page refresh. This means you
must think differently about how you
organize and handle your Javascript.
Your application is now a long living
Javascript application.
You must be wary of memory leaks. This
means ensuring no circular references and
writing your Javascript in a way that allows
for garbage collection when the controller
changes actions.

Recommended for you

Putting the Cat in the Catalogue: A Feline-Inspired OPAC Theme For Koha
Putting the Cat in the Catalogue: A Feline-Inspired OPAC Theme For KohaPutting the Cat in the Catalogue: A Feline-Inspired OPAC Theme For Koha
Putting the Cat in the Catalogue: A Feline-Inspired OPAC Theme For Koha

Lightning talk at the Code4Lib British Columbia meeting on 27 November 2014, presenting a jQuery plugin for adding unAPI visibility (and cats!) to library catalogs.

librariesegilskoha
Server Side Swift with Swag
Server Side Swift with SwagServer Side Swift with Swag
Server Side Swift with Swag

Swift on Linux is finally there. What about building your next big coding project in Swift instead of Rails or node.js?

servermeetuptalk
Moving from Django Apps to Services
Moving from Django Apps to ServicesMoving from Django Apps to Services
Moving from Django Apps to Services

This document discusses converting Django apps into reusable services. It begins by explaining the typical structure of a Django project with multiple apps. It then discusses some of the challenges with this monolithic structure in terms of reusability, scalability and maintainability. The document proposes converting apps into reusable services with defined contracts for communication. It provides examples of defining API endpoints and authentication. Converting apps to services allows for improved reusability as apps can be developed and updated independently. It also enables better scalability by removing dependencies between apps.

programmingpythondjango
$(document).on('page:load', function() {
// wire up javascript events for a page load
});
$(document).on('page:before-unload', function() {
// cleanup references from before
});
This means that just about every jQuery
plugin you may find will cause memory
leaks.
Most of these plugins are poorly
designed and
with a fresh page load in mind. They
don’t tend to track references or have a
way to clean them up.
al solutions to these problems that we’ve all tri
if ($('.organization').length > 0) {
$('.organization').each(function(index, element) {
var $el = $(element);
$.getJSON('/meetup/group/' + $el.prop('data-meetup-id'),
function(data) {
$el.find('a.title').prop('href', 'http://meetup.com/'
+ data.meetup_id)
$el.find('a.title h1').html(data.title);
$el.find('span.members').html(data.members_count);
$el.find('img.meetup-logo').html(data.images.group_logo_large);
});
});
}

Recommended for you

Take Better Care of Library Data and Spreadsheets with Google Visualization A...
Take Better Care of Library Data and Spreadsheets with Google Visualization A...Take Better Care of Library Data and Spreadsheets with Google Visualization A...
Take Better Care of Library Data and Spreadsheets with Google Visualization A...

Presentation given at 2013 LITA Forum on Nov 8, 2013. http://www.ala.org/lita/conferences/forum/2013 ; Example files are at http://github.com/bohyunkim/examples

dataspreadsheetapi
Crossing platforms with JavaScript & React
Crossing platforms with JavaScript & React Crossing platforms with JavaScript & React
Crossing platforms with JavaScript & React

In this talk I explore just how much code you can share between a react web project and a react native project.

reactjavascriptandroid
jQuery & 10,000 Global Functions: Working with Legacy JavaScript
jQuery & 10,000 Global Functions: Working with Legacy JavaScriptjQuery & 10,000 Global Functions: Working with Legacy JavaScript
jQuery & 10,000 Global Functions: Working with Legacy JavaScript

Long ago, in the late days of the first Internet boom, before jQuery, before Underscore, before Angular, there was a web application built by a large corporation. This application was written as a server-side application using server-side technology like Java or PHP. A tiny seed of JavaScript was added to some of the pages of this application to give it a little sizzle. Over the ages, this tiny bit of JavaScript grew like kudzu. Most of it was embedded in the HTML in

refactoringjavascriptlegacy
Now HTML is rendered by Rails and we
have this pyramid of doom to update our
content.
What if we needed logic for different
pieces?
What if the Meetup API starts replying with
varying data based on something in their
state?
What if we want to poll repeatedly for
changes?
We could move HTML rendering to
templates and now we need another
gem to precompile
Handlebars/Jade/Haml Javascript
templates. Even more logic going in to
this single function.
ot a good fit for this style of development. They
Enter React
React is the light-weight functional view layer
from Facebook designed for building UIs with a
focus on immutable data structures.

Recommended for you

Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applications

Avoid misery of working with legacy code We will see how you can add independent and isolated components to existing pages; pages that may be difficult to change React and Flux allow you to make self-contained additions that handle their own data access/persistence

reactweb developmentbrowserify
A Little Backbone For Your App
A Little Backbone For Your AppA Little Backbone For Your App
A Little Backbone For Your App

Backbone.js presentation at JSDay 2011: http://www.jsday.it/2011/archive/talk/a-little-backbone-for-your-app

backbonejsjavascriptjsday
Backbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVCBackbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVC

Philip Poots is a Ruby developer who works at Audacio.us. He focuses on structure frameworks, state applications, and speed with JavaScript.

backbonejsclient side javascriptdevelopment frameworks
React is designing your UI around
reusable and self-contained components.
No separation of files with controllers,
views, templates and models. Allows for
ease of maintainability for even the most of
Javascript novices.
React has a wonderfully simple API that
will take 15 minutes to learn.
OrganizationImage
OrganizationEvent
OrganizationName
OrganizationMembers
var Organization = React.createClass({
componentWillMount: function() {
$.getJSON('/meetup/group/' + this.props.meetup_id)
.then(function(json) {
this.setState(json);
}.bind(this));
},
meetupURL: function(path) {
return "http://www.meetup.com/" +
this.props.meetup_id + path;
},
render: function() {
return <div>
<OrganizationImage photos={this.state.group_photo} />
<OrganizationName name={this.state.name}
meetupURL={this.meetupURL} />
<OrganizationEvent event={this.state.next_event}
meetupURL={this.meetupURL} />
<OrganizationMembers members={this.state.members}
meetupURL={this.meetupURL} />
</div>;
}
});

Recommended for you

Javascript first-class citizenery
Javascript first-class citizeneryJavascript first-class citizenery
Javascript first-class citizenery

Javascript and first-class citizenry: require.js & node.js Javascript on web pages is ubiquitous and its problems are legendary. Javascript, seen as a second-class code citizen, is usually hacked together even by seasoned developers. New libraries (jQuery, prototype, backbone, knockout, underscore) and runtime tools (firebug, jasmine) look like they solve many problems - and they do. But they still leave poorly written code as just that. One key problem is that all javascript code lives globally and this results in poorly managed, tested and delivered code. In this session, I will illustrate that we can treat javascript as a first-class citizen using with require.js and node.js: it can be modular, encapsulated and easily unit tested and added to continuous integration cycle. The dependencies between javascript modules can also be managed and packaged just like in C# and Java. In the end, we can resolve many javascript difficulties at compile time rather than waiting until runtime.

javascript requirejs node.js
Building Large jQuery Applications
Building Large jQuery ApplicationsBuilding Large jQuery Applications
Building Large jQuery Applications

When you move beyond adding simple enhancements to your website with jQuery and start building full-blown client-side applications, how do you organize your code? At this month's Triangle JS Meetup, we'll take a look at patterns for application development using jQuery that promote the principles of tight encapsulation and loose coupling, including classes, the publish/subscribe paradigm, and dependency management and build systems.

javascriptjquery
Understanding backbonejs
Understanding backbonejsUnderstanding backbonejs
Understanding backbonejs

This document provides an overview of using the Backbone.js framework for client-side MVC applications. It discusses why Backbone is useful for structuring JavaScript applications, its core architecture including models, collections, views and routers. It also provides examples of how to convert jQuery code to use a Backbone-based approach and lists some real-world applications that use Backbone.

backbonejs
React is designed around a one-way data
flow. Views are considered to be
immutable and state should be kept to
single place.
When state changes the views are
created from scratch and render and all
mutated state/properties are replaced.
var Organization = React.createClass({
componentWillMount: function() {
$.getJSON('/meetup/group/' + this.props.meetup_id).then(function(json) {
this.setState(json);
}.bind(this));
},
meetupURL: function(path) {
return "http://www.meetup.com/" + this.props.meetup_id + path;
},
render: function() {
return <div>
<OrganizationImage photos={this.state.group_photo} />
</div>;
}
});
var OrganizationImage = React.createClass({
render: function() {
return <img src={this.props.photos.highres_link} width="80" height="80"/>;
}
});
data. What about collecting data or doing things
t unidirectional flow. Data goes down and eve

Recommended for you

huhu
huhuhuhu
huhu

This document discusses using jQuery and Google App Engine to create cross-domain web mashups in 3 sentences or less: The document introduces techniques for creating cross-domain web mashups using jQuery to make AJAX calls across domains and Google App Engine for hosting, discussing JSONP and proxies to overcome the same-origin policy limitation. It then provides an example mashup that displays tweets tagged with a hashtag on a map by geocoding hashtag names to locations and querying Twitter, Google Maps, and other domains.

Cross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App EngineCross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App Engine

This document discusses cross-domain mashups using jQuery and Google App Engine. It describes common techniques for dealing with the same-origin policy, including proxies, JSONP, and building sample applications that mashup Twitter data, geotagged tweets, and maps. Examples include parsing RSS feeds from Twitter into JSONP and displaying tweets on a map based on their geotagged locations. The document concludes by noting issues with trust, failures, and limitations for enterprise use.

jsonpappenginejquery
JS-05-Handlebars.ppt
JS-05-Handlebars.pptJS-05-Handlebars.ppt
JS-05-Handlebars.ppt

The document discusses Handlebars, a templating language for HTML. It can be used to render dynamic HTML views from JSON data sources by using templates with placeholders that are replaced by values from a context object. An example demonstrates creating a template, compiling it, providing a context with sample data, and rendering the template to insert the dynamic HTML into the page. Handlebars allows separation of design and data for model-view-controller applications.

why was the end of Lost so bad?
SearchAutocomplete
var SearchAutocomplete = React.createClass({
handleAutocomplete: function(event) {
var query = event.target.value;
this.setState({ searchQuery: query });
$.getJSON(this.props.autocompleteUrl, { q: query })
.then(function(autocompleteOptions) {
this.setState({ options: autocompleteOptions });
});
},
render: function() {
return <div>
<SearchAutocompleteInput value={this.state.searchQuery}
handleChange={this.handleAutocomplete} />
<SearchAutocompleteResults options={this.state.options} />
</div>;
}
});
AutocompleteSearchInput
AutocompleteSearchResult
s
var SearchAutocomplete = React.createClass({
handleAutocomplete: function(event) {
var query = event.target.value;
this.setState({ searchQuery: query });
$.getJSON(this.props.autocompleteUrl, { q: query })
.then(function(autocompleteOptions) {
this.setState({ options: autocompleteOptions });
});
},
render: function() {
return <div>
<SearchAutocompleteInput value={this.state.searchQuery}
handleChange={this.handleAutocomplete} />
<SearchAutocompleteResults options={this.state.options} />
</div>;
}
});

Recommended for you

Html5 and web technology update
Html5 and web technology updateHtml5 and web technology update
Html5 and web technology update

An introduction to modern web technologies HTML5, including Offline, Storage, and Canvas Embedded JavaScript RESTful WebServices using MVC 3, jQuery, and JSON Going mobile with PhoneGap and HTML and CSS

After max+phonegap
After max+phonegapAfter max+phonegap
After max+phonegap

This document discusses building mobile applications using PhoneGap, jQuery, and Dreamweaver. It provides an overview of different mobile application types including mobile HTML, web apps, hybrid apps, and native apps. It then demonstrates how to create hybrid mobile apps with PhoneGap and jQuery Mobile, including accessing device APIs, building user interfaces with jQuery Mobile, and creating customizable PhoneGap plugins.

混搭移动开发:PhoneGap+JQurey+Dreamweaver
混搭移动开发:PhoneGap+JQurey+Dreamweaver混搭移动开发:PhoneGap+JQurey+Dreamweaver
混搭移动开发:PhoneGap+JQurey+Dreamweaver

This document discusses building mobile applications using PhoneGap, jQuery, and Dreamweaver. It provides an overview of different mobile application types including mobile HTML, web apps, hybrid apps, and native apps. It then demonstrates how to create hybrid mobile apps with PhoneGap and jQuery Mobile, including accessing device APIs, building user interfaces with jQuery Mobile, and creating lists and charts with JavaScript plugins. It also covers how to package and deploy the app to different platforms using PhoneGap.

webapp,phonegap
Progressive Enhancment with Rails and React
Whats with all the Javascript? Isn’t this
about Rails?
gem 'react-rails'
unctionality and dependencies of React while t

Recommended for you

Dependency Management with RequireJS
Dependency Management with RequireJSDependency Management with RequireJS
Dependency Management with RequireJS

This document provides an overview of dependency management with RequireJS. It defines key concepts like modules, AMD, and RequireJS. It demonstrates how to define modules, request dependencies, and configure RequireJS. It also covers more advanced topics like defining constructor modules, configuring paths and shimming non-AMD libraries, using plugins, conditional dependencies, error handling, and optimization.

amdmoduledependency management
Asynchronous Interfaces
Asynchronous InterfacesAsynchronous Interfaces
Asynchronous Interfaces

This document discusses various tools and libraries for building real-time web applications, including SuperClass for simple class abstraction, SuperApp for building state-based applications, SuperModel for object-relational mapping, SuperConnect for templating and binding, SuperRPC for JSON-RPC, and Juggernaut for real-time functionality through websockets. It also briefly mentions other utilities like Sprockets for asset packaging and FileReader for reading file uploads.

Styling components with JavaScript
Styling components with JavaScriptStyling components with JavaScript
Styling components with JavaScript

The document discusses using JavaScript to style components instead of CSS. It describes how React allows defining styles inline but that is not ideal. The author explores using Webpack and React-style to define styles within components in JavaScript and have them automatically output to a stylesheet. This avoids separating styles across files while keeping styles tightly coupled to components. The document argues JavaScript is well-suited as a "preprocessor" for generating styles and provides examples of using variables, functions and loops to generate styles programmatically.

Remember the Organization component?
<% @organizations.each do |organization| %>
<%= react_component('Organization',
organization.to_json) %>
<% end %>
Mounts the React component
Sets the properties of the component
from the given hash
Automatically cleans up references and
handles memory management with
Turbolinks callbacks
But what about SEO and search
engine crawling?

Recommended for you

Integrating React.js Into a PHP Application
Integrating React.js Into a PHP ApplicationIntegrating React.js Into a PHP Application
Integrating React.js Into a PHP Application

React.js has taken the web development world by storm, and for good reason: React offers a declarative, component-oriented approach to building highly-scalable web UIs. But how can we take advantage of a JavaScript library like React in our server-side PHP applications. In this talk l cover the different ways React.js can be integrated into an existing PHP web application: from a client-side only approach to multiple techniques that support full server-side rendering with a Node.js server or PHP’s v8js. I also discuss the trade-offs in each of these designs and the challenges involved with adding React to a PHP site. Most importantly, I consider the higher-level issue of how to improve view cohesion across the client-server divide in a PHP application.

react.jsjavascriptphp
Big Data for each one of us
Big Data for each one of usBig Data for each one of us
Big Data for each one of us

This document discusses how big data and analytics can be used by individuals. It notes that while people used to be able to work alone, big data now requires teams of people. It provides examples of how a team of 1 person grew to 4 people and later 10 people to work on an analytics project over 3 months. It also discusses technologies like REST APIs, Java, RequireJS, Mustache templates, and how they were used to develop applications and widgets to work with and visualize different data sources.

Frontin like-a-backer
Frontin like-a-backerFrontin like-a-backer
Frontin like-a-backer

The document discusses the evolution of the author's views on JavaScript and front-end frameworks. It begins by expressing dislike for JavaScript but acknowledging the need for it. Various frameworks like Backbone, Angular, and Ember are explored but found lacking. React is then introduced and praised for its declarative and composable approach similar to HTML. The author comes to understand JSX and how React implements unidirectional data flow to separate the UI from data logic. This allows building full-stack applications with React handling both client and server rendering based on shared intentions, state, and data flow patterns.

php laraconeu
<%= react_component('Organization',
organization.to_json, prerender: true) %>
Progressive Enhancment with Rails and React
React knows how to pre-render using
ExecJS so the component will boot
using the existing HTML that is valid
for React.
I’ve come full circle on my thinking of front
end development.
Rails development feels better than every
alternative, no matter how polished. React
and React-Rails allows for a really great
convergence of great and fast front end
tooling with Rails fast development
cycle.

Recommended for you

Natural Is The Best: Model-Agnostic Code Simplification for Pre-trained Large...
Natural Is The Best: Model-Agnostic Code Simplification for Pre-trained Large...Natural Is The Best: Model-Agnostic Code Simplification for Pre-trained Large...
Natural Is The Best: Model-Agnostic Code Simplification for Pre-trained Large...

Pre-trained Large Language Models (LLM) have achieved remarkable successes in several domains. However, code-oriented LLMs are often heavy in computational complexity, and quadratically with the length of the input code sequence. Toward simplifying the input program of an LLM, the state-of-the-art approach has the strategies to filter the input code tokens based on the attention scores given by the LLM. The decision to simplify the input program should not rely on the attention patterns of an LLM, as these patterns are influenced by both the model architecture and the pre-training dataset. Since the model and dataset are part of the solution domain, not the problem domain where the input program belongs, the outcome may differ when the model is trained on a different dataset. We propose SlimCode, a model-agnostic code simplification solution for LLMs that depends on the nature of input code tokens. As an empirical study on the LLMs including CodeBERT, CodeT5, and GPT-4 for two main tasks: code search and summarization. We reported that 1) the reduction ratio of code has a linear-like relation with the saving ratio on training time, 2) the impact of categorized tokens on code simplification can vary significantly, 3) the impact of categorized tokens on code simplification is task-specific but model-agnostic, and 4) the above findings hold for the paradigm–prompt engineering and interactive in-context learning and this study can save reduce the cost of invoking GPT-4 by 24%per API query. Importantly, SlimCode simplifies the input code with its greedy strategy and can obtain at most 133 times faster than the state-of-the-art technique with a significant improvement. This paper calls for a new direction on code-based, model-agnostic code simplification solutions to further empower LLMs.

code simplification
L-3536-Cost Benifit Analysis in ESIA.pptx
L-3536-Cost Benifit Analysis in ESIA.pptxL-3536-Cost Benifit Analysis in ESIA.pptx
L-3536-Cost Benifit Analysis in ESIA.pptx

..

Net Zero Case Study: SRK House and SRK Empire
Net Zero Case Study: SRK House and SRK EmpireNet Zero Case Study: SRK House and SRK Empire
Net Zero Case Study: SRK House and SRK Empire

In May 2024, globally renowned natural diamond crafting company Shree Ramkrishna Exports Pvt. Ltd. (SRK) became the first company in the world to achieve GNFZ’s final net zero certification for existing buildings, for its two two flagship crafting facilities SRK House and SRK Empire. Initially targeting 2030 to reach net zero, SRK joined forces with the Global Network for Zero (GNFZ) to accelerate its target to 2024 — a trailblazing achievement toward emissions elimination.

energybuildingconstruction
Go forth and try React with Rails!
Questions? Comments?

More Related Content

What's hot

Spca2014 hillier 3rd party_javascript_libraries
Spca2014 hillier 3rd party_javascript_librariesSpca2014 hillier 3rd party_javascript_libraries
Spca2014 hillier 3rd party_javascript_libraries
NCCOMMS
 
Jqeury ajax plugins
Jqeury ajax pluginsJqeury ajax plugins
Jqeury ajax plugins
Inbal Geffen
 
(Updated) SharePoint & jQuery Guide
(Updated) SharePoint & jQuery Guide(Updated) SharePoint & jQuery Guide
(Updated) SharePoint & jQuery Guide
Mark Rackley
 
Assumptions: Check yo'self before you wreck yourself
Assumptions: Check yo'self before you wreck yourselfAssumptions: Check yo'self before you wreck yourself
Assumptions: Check yo'self before you wreck yourself
Erin Shellman
 
Introduction to AngularJS For WordPress Developers
Introduction to AngularJS For WordPress DevelopersIntroduction to AngularJS For WordPress Developers
Introduction to AngularJS For WordPress Developers
Caldera Labs
 
Two Webs! : combining the best of Web 1.0, Web 2.0 and the Semantic Web
Two Webs! : combining the best of Web 1.0, Web 2.0 and the Semantic WebTwo Webs! : combining the best of Web 1.0, Web 2.0 and the Semantic Web
Two Webs! : combining the best of Web 1.0, Web 2.0 and the Semantic Web
Danny Ayers
 
ApacheCon 2005
ApacheCon 2005ApacheCon 2005
ApacheCon 2005
Adam Trachtenberg
 
Search APIs in Spotlight and Safari
Search APIs in Spotlight and SafariSearch APIs in Spotlight and Safari
Search APIs in Spotlight and Safari
Yusuke Kita
 
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014Hardcore URL Routing for WordPress - WordCamp Atlanta 2014
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014
Mike Schinkel
 
Create responsive websites with Django, REST and AngularJS
Create responsive websites with Django, REST and AngularJSCreate responsive websites with Django, REST and AngularJS
Create responsive websites with Django, REST and AngularJS
Hannes Hapke
 
An Overview of Models in Django
An Overview of Models in DjangoAn Overview of Models in Django
An Overview of Models in Django
Michael Auritt
 
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
Mike Schinkel
 
Putting the Cat in the Catalogue: A Feline-Inspired OPAC Theme For Koha
Putting the Cat in the Catalogue: A Feline-Inspired OPAC Theme For KohaPutting the Cat in the Catalogue: A Feline-Inspired OPAC Theme For Koha
Putting the Cat in the Catalogue: A Feline-Inspired OPAC Theme For Koha
Galen Charlton
 
Server Side Swift with Swag
Server Side Swift with SwagServer Side Swift with Swag
Server Side Swift with Swag
Jens Ravens
 
Moving from Django Apps to Services
Moving from Django Apps to ServicesMoving from Django Apps to Services
Moving from Django Apps to Services
Craig Kerstiens
 
Take Better Care of Library Data and Spreadsheets with Google Visualization A...
Take Better Care of Library Data and Spreadsheets with Google Visualization A...Take Better Care of Library Data and Spreadsheets with Google Visualization A...
Take Better Care of Library Data and Spreadsheets with Google Visualization A...
Bohyun Kim
 

What's hot (16)

Spca2014 hillier 3rd party_javascript_libraries
Spca2014 hillier 3rd party_javascript_librariesSpca2014 hillier 3rd party_javascript_libraries
Spca2014 hillier 3rd party_javascript_libraries
 
Jqeury ajax plugins
Jqeury ajax pluginsJqeury ajax plugins
Jqeury ajax plugins
 
(Updated) SharePoint & jQuery Guide
(Updated) SharePoint & jQuery Guide(Updated) SharePoint & jQuery Guide
(Updated) SharePoint & jQuery Guide
 
Assumptions: Check yo'self before you wreck yourself
Assumptions: Check yo'self before you wreck yourselfAssumptions: Check yo'self before you wreck yourself
Assumptions: Check yo'self before you wreck yourself
 
Introduction to AngularJS For WordPress Developers
Introduction to AngularJS For WordPress DevelopersIntroduction to AngularJS For WordPress Developers
Introduction to AngularJS For WordPress Developers
 
Two Webs! : combining the best of Web 1.0, Web 2.0 and the Semantic Web
Two Webs! : combining the best of Web 1.0, Web 2.0 and the Semantic WebTwo Webs! : combining the best of Web 1.0, Web 2.0 and the Semantic Web
Two Webs! : combining the best of Web 1.0, Web 2.0 and the Semantic Web
 
ApacheCon 2005
ApacheCon 2005ApacheCon 2005
ApacheCon 2005
 
Search APIs in Spotlight and Safari
Search APIs in Spotlight and SafariSearch APIs in Spotlight and Safari
Search APIs in Spotlight and Safari
 
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014Hardcore URL Routing for WordPress - WordCamp Atlanta 2014
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014
 
Create responsive websites with Django, REST and AngularJS
Create responsive websites with Django, REST and AngularJSCreate responsive websites with Django, REST and AngularJS
Create responsive websites with Django, REST and AngularJS
 
An Overview of Models in Django
An Overview of Models in DjangoAn Overview of Models in Django
An Overview of Models in Django
 
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
 
Putting the Cat in the Catalogue: A Feline-Inspired OPAC Theme For Koha
Putting the Cat in the Catalogue: A Feline-Inspired OPAC Theme For KohaPutting the Cat in the Catalogue: A Feline-Inspired OPAC Theme For Koha
Putting the Cat in the Catalogue: A Feline-Inspired OPAC Theme For Koha
 
Server Side Swift with Swag
Server Side Swift with SwagServer Side Swift with Swag
Server Side Swift with Swag
 
Moving from Django Apps to Services
Moving from Django Apps to ServicesMoving from Django Apps to Services
Moving from Django Apps to Services
 
Take Better Care of Library Data and Spreadsheets with Google Visualization A...
Take Better Care of Library Data and Spreadsheets with Google Visualization A...Take Better Care of Library Data and Spreadsheets with Google Visualization A...
Take Better Care of Library Data and Spreadsheets with Google Visualization A...
 

Similar to Progressive Enhancment with Rails and React

Crossing platforms with JavaScript & React
Crossing platforms with JavaScript & React Crossing platforms with JavaScript & React
Crossing platforms with JavaScript & React
Robert DeLuca
 
jQuery & 10,000 Global Functions: Working with Legacy JavaScript
jQuery & 10,000 Global Functions: Working with Legacy JavaScriptjQuery & 10,000 Global Functions: Working with Legacy JavaScript
jQuery & 10,000 Global Functions: Working with Legacy JavaScript
Guy Royse
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applications
Jeff Durta
 
A Little Backbone For Your App
A Little Backbone For Your AppA Little Backbone For Your App
A Little Backbone For Your App
Luca Mearelli
 
Backbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVCBackbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVC
pootsbook
 
Javascript first-class citizenery
Javascript first-class citizeneryJavascript first-class citizenery
Javascript first-class citizenery
toddbr
 
Building Large jQuery Applications
Building Large jQuery ApplicationsBuilding Large jQuery Applications
Building Large jQuery Applications
Rebecca Murphey
 
Understanding backbonejs
Understanding backbonejsUnderstanding backbonejs
Understanding backbonejs
Nick Lee
 
huhu
huhuhuhu
Cross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App EngineCross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App Engine
Andy McKay
 
JS-05-Handlebars.ppt
JS-05-Handlebars.pptJS-05-Handlebars.ppt
JS-05-Handlebars.ppt
fakeaccount225095
 
Html5 and web technology update
Html5 and web technology updateHtml5 and web technology update
Html5 and web technology update
Doug Domeny
 
After max+phonegap
After max+phonegapAfter max+phonegap
After max+phonegap
yangdj
 
混搭移动开发:PhoneGap+JQurey+Dreamweaver
混搭移动开发:PhoneGap+JQurey+Dreamweaver混搭移动开发:PhoneGap+JQurey+Dreamweaver
混搭移动开发:PhoneGap+JQurey+Dreamweaver
yangdj
 
Dependency Management with RequireJS
Dependency Management with RequireJSDependency Management with RequireJS
Dependency Management with RequireJS
Aaronius
 
Asynchronous Interfaces
Asynchronous InterfacesAsynchronous Interfaces
Asynchronous Interfaces
maccman
 
Styling components with JavaScript
Styling components with JavaScriptStyling components with JavaScript
Styling components with JavaScript
bensmithett
 
Integrating React.js Into a PHP Application
Integrating React.js Into a PHP ApplicationIntegrating React.js Into a PHP Application
Integrating React.js Into a PHP Application
Andrew Rota
 
Big Data for each one of us
Big Data for each one of usBig Data for each one of us
Big Data for each one of us
OSCON Byrum
 
Frontin like-a-backer
Frontin like-a-backerFrontin like-a-backer
Frontin like-a-backer
Frank de Jonge
 

Similar to Progressive Enhancment with Rails and React (20)

Crossing platforms with JavaScript & React
Crossing platforms with JavaScript & React Crossing platforms with JavaScript & React
Crossing platforms with JavaScript & React
 
jQuery & 10,000 Global Functions: Working with Legacy JavaScript
jQuery & 10,000 Global Functions: Working with Legacy JavaScriptjQuery & 10,000 Global Functions: Working with Legacy JavaScript
jQuery & 10,000 Global Functions: Working with Legacy JavaScript
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applications
 
A Little Backbone For Your App
A Little Backbone For Your AppA Little Backbone For Your App
A Little Backbone For Your App
 
Backbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVCBackbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVC
 
Javascript first-class citizenery
Javascript first-class citizeneryJavascript first-class citizenery
Javascript first-class citizenery
 
Building Large jQuery Applications
Building Large jQuery ApplicationsBuilding Large jQuery Applications
Building Large jQuery Applications
 
Understanding backbonejs
Understanding backbonejsUnderstanding backbonejs
Understanding backbonejs
 
huhu
huhuhuhu
huhu
 
Cross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App EngineCross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App Engine
 
JS-05-Handlebars.ppt
JS-05-Handlebars.pptJS-05-Handlebars.ppt
JS-05-Handlebars.ppt
 
Html5 and web technology update
Html5 and web technology updateHtml5 and web technology update
Html5 and web technology update
 
After max+phonegap
After max+phonegapAfter max+phonegap
After max+phonegap
 
混搭移动开发:PhoneGap+JQurey+Dreamweaver
混搭移动开发:PhoneGap+JQurey+Dreamweaver混搭移动开发:PhoneGap+JQurey+Dreamweaver
混搭移动开发:PhoneGap+JQurey+Dreamweaver
 
Dependency Management with RequireJS
Dependency Management with RequireJSDependency Management with RequireJS
Dependency Management with RequireJS
 
Asynchronous Interfaces
Asynchronous InterfacesAsynchronous Interfaces
Asynchronous Interfaces
 
Styling components with JavaScript
Styling components with JavaScriptStyling components with JavaScript
Styling components with JavaScript
 
Integrating React.js Into a PHP Application
Integrating React.js Into a PHP ApplicationIntegrating React.js Into a PHP Application
Integrating React.js Into a PHP Application
 
Big Data for each one of us
Big Data for each one of usBig Data for each one of us
Big Data for each one of us
 
Frontin like-a-backer
Frontin like-a-backerFrontin like-a-backer
Frontin like-a-backer
 

Recently uploaded

Natural Is The Best: Model-Agnostic Code Simplification for Pre-trained Large...
Natural Is The Best: Model-Agnostic Code Simplification for Pre-trained Large...Natural Is The Best: Model-Agnostic Code Simplification for Pre-trained Large...
Natural Is The Best: Model-Agnostic Code Simplification for Pre-trained Large...
YanKing2
 
L-3536-Cost Benifit Analysis in ESIA.pptx
L-3536-Cost Benifit Analysis in ESIA.pptxL-3536-Cost Benifit Analysis in ESIA.pptx
L-3536-Cost Benifit Analysis in ESIA.pptx
naseki5964
 
Net Zero Case Study: SRK House and SRK Empire
Net Zero Case Study: SRK House and SRK EmpireNet Zero Case Study: SRK House and SRK Empire
Net Zero Case Study: SRK House and SRK Empire
Global Network for Zero
 
Exploring Deep Learning Models for Image Recognition: A Comparative Review
Exploring Deep Learning Models for Image Recognition: A Comparative ReviewExploring Deep Learning Models for Image Recognition: A Comparative Review
Exploring Deep Learning Models for Image Recognition: A Comparative Review
sipij
 
Rotary Intersection in traffic engineering.pptx
Rotary Intersection in traffic engineering.pptxRotary Intersection in traffic engineering.pptx
Rotary Intersection in traffic engineering.pptx
surekha1287
 
Quadcopter Dynamics, Stability and Control
Quadcopter Dynamics, Stability and ControlQuadcopter Dynamics, Stability and Control
Quadcopter Dynamics, Stability and Control
Blesson Easo Varghese
 
Unblocking The Main Thread - Solving ANRs and Frozen Frames
Unblocking The Main Thread - Solving ANRs and Frozen FramesUnblocking The Main Thread - Solving ANRs and Frozen Frames
Unblocking The Main Thread - Solving ANRs and Frozen Frames
Sinan KOZAK
 
Best Practices of Clothing Businesses in Talavera, Nueva Ecija, A Foundation ...
Best Practices of Clothing Businesses in Talavera, Nueva Ecija, A Foundation ...Best Practices of Clothing Businesses in Talavera, Nueva Ecija, A Foundation ...
Best Practices of Clothing Businesses in Talavera, Nueva Ecija, A Foundation ...
IJAEMSJORNAL
 
CCS367-STORAGE TECHNOLOGIES QUESTION BANK.doc
CCS367-STORAGE TECHNOLOGIES QUESTION BANK.docCCS367-STORAGE TECHNOLOGIES QUESTION BANK.doc
CCS367-STORAGE TECHNOLOGIES QUESTION BANK.doc
Dss
 
IS Code SP 23: Handbook on concrete mixes
IS Code SP 23: Handbook  on concrete mixesIS Code SP 23: Handbook  on concrete mixes
IS Code SP 23: Handbook on concrete mixes
Mani Krishna Sarkar
 
21EC63_Module1B.pptx VLSI design 21ec63 MOS TRANSISTOR THEORY
21EC63_Module1B.pptx VLSI design 21ec63 MOS TRANSISTOR THEORY21EC63_Module1B.pptx VLSI design 21ec63 MOS TRANSISTOR THEORY
21EC63_Module1B.pptx VLSI design 21ec63 MOS TRANSISTOR THEORY
PradeepKumarSK3
 
22519 - Client-Side Scripting Language (CSS) chapter 1 notes .pdf
22519 - Client-Side Scripting Language (CSS) chapter 1 notes .pdf22519 - Client-Side Scripting Language (CSS) chapter 1 notes .pdf
22519 - Client-Side Scripting Language (CSS) chapter 1 notes .pdf
sharvaridhokte
 
Bangalore @ℂall @Girls ꧁❤ 0000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe
Bangalore @ℂall @Girls ꧁❤ 0000000000 ❤꧂@ℂall @Girls Service Vip Top Model SafeBangalore @ℂall @Girls ꧁❤ 0000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe
Bangalore @ℂall @Girls ꧁❤ 0000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe
bookhotbebes1
 
Conservation of Taksar through Economic Regeneration
Conservation of Taksar through Economic RegenerationConservation of Taksar through Economic Regeneration
Conservation of Taksar through Economic Regeneration
PriyankaKarn3
 
Understanding Cybersecurity Breaches: Causes, Consequences, and Prevention
Understanding Cybersecurity Breaches: Causes, Consequences, and PreventionUnderstanding Cybersecurity Breaches: Causes, Consequences, and Prevention
Understanding Cybersecurity Breaches: Causes, Consequences, and Prevention
Bert Blevins
 
Online music portal management system project report.pdf
Online music portal management system project report.pdfOnline music portal management system project report.pdf
Online music portal management system project report.pdf
Kamal Acharya
 
1239_2.pdf IS CODE FOR GI PIPE FOR PROCUREMENT
1239_2.pdf IS CODE FOR GI PIPE FOR PROCUREMENT1239_2.pdf IS CODE FOR GI PIPE FOR PROCUREMENT
1239_2.pdf IS CODE FOR GI PIPE FOR PROCUREMENT
Mani Krishna Sarkar
 
Advances in Detect and Avoid for Unmanned Aircraft Systems and Advanced Air M...
Advances in Detect and Avoid for Unmanned Aircraft Systems and Advanced Air M...Advances in Detect and Avoid for Unmanned Aircraft Systems and Advanced Air M...
Advances in Detect and Avoid for Unmanned Aircraft Systems and Advanced Air M...
VICTOR MAESTRE RAMIREZ
 
Software Engineering and Project Management - Introduction to Project Management
Software Engineering and Project Management - Introduction to Project ManagementSoftware Engineering and Project Management - Introduction to Project Management
Software Engineering and Project Management - Introduction to Project Management
Prakhyath Rai
 
UNIT I INCEPTION OF INFORMATION DESIGN 20CDE09-ID
UNIT I INCEPTION OF INFORMATION DESIGN 20CDE09-IDUNIT I INCEPTION OF INFORMATION DESIGN 20CDE09-ID
UNIT I INCEPTION OF INFORMATION DESIGN 20CDE09-ID
GOWSIKRAJA PALANISAMY
 

Recently uploaded (20)

Natural Is The Best: Model-Agnostic Code Simplification for Pre-trained Large...
Natural Is The Best: Model-Agnostic Code Simplification for Pre-trained Large...Natural Is The Best: Model-Agnostic Code Simplification for Pre-trained Large...
Natural Is The Best: Model-Agnostic Code Simplification for Pre-trained Large...
 
L-3536-Cost Benifit Analysis in ESIA.pptx
L-3536-Cost Benifit Analysis in ESIA.pptxL-3536-Cost Benifit Analysis in ESIA.pptx
L-3536-Cost Benifit Analysis in ESIA.pptx
 
Net Zero Case Study: SRK House and SRK Empire
Net Zero Case Study: SRK House and SRK EmpireNet Zero Case Study: SRK House and SRK Empire
Net Zero Case Study: SRK House and SRK Empire
 
Exploring Deep Learning Models for Image Recognition: A Comparative Review
Exploring Deep Learning Models for Image Recognition: A Comparative ReviewExploring Deep Learning Models for Image Recognition: A Comparative Review
Exploring Deep Learning Models for Image Recognition: A Comparative Review
 
Rotary Intersection in traffic engineering.pptx
Rotary Intersection in traffic engineering.pptxRotary Intersection in traffic engineering.pptx
Rotary Intersection in traffic engineering.pptx
 
Quadcopter Dynamics, Stability and Control
Quadcopter Dynamics, Stability and ControlQuadcopter Dynamics, Stability and Control
Quadcopter Dynamics, Stability and Control
 
Unblocking The Main Thread - Solving ANRs and Frozen Frames
Unblocking The Main Thread - Solving ANRs and Frozen FramesUnblocking The Main Thread - Solving ANRs and Frozen Frames
Unblocking The Main Thread - Solving ANRs and Frozen Frames
 
Best Practices of Clothing Businesses in Talavera, Nueva Ecija, A Foundation ...
Best Practices of Clothing Businesses in Talavera, Nueva Ecija, A Foundation ...Best Practices of Clothing Businesses in Talavera, Nueva Ecija, A Foundation ...
Best Practices of Clothing Businesses in Talavera, Nueva Ecija, A Foundation ...
 
CCS367-STORAGE TECHNOLOGIES QUESTION BANK.doc
CCS367-STORAGE TECHNOLOGIES QUESTION BANK.docCCS367-STORAGE TECHNOLOGIES QUESTION BANK.doc
CCS367-STORAGE TECHNOLOGIES QUESTION BANK.doc
 
IS Code SP 23: Handbook on concrete mixes
IS Code SP 23: Handbook  on concrete mixesIS Code SP 23: Handbook  on concrete mixes
IS Code SP 23: Handbook on concrete mixes
 
21EC63_Module1B.pptx VLSI design 21ec63 MOS TRANSISTOR THEORY
21EC63_Module1B.pptx VLSI design 21ec63 MOS TRANSISTOR THEORY21EC63_Module1B.pptx VLSI design 21ec63 MOS TRANSISTOR THEORY
21EC63_Module1B.pptx VLSI design 21ec63 MOS TRANSISTOR THEORY
 
22519 - Client-Side Scripting Language (CSS) chapter 1 notes .pdf
22519 - Client-Side Scripting Language (CSS) chapter 1 notes .pdf22519 - Client-Side Scripting Language (CSS) chapter 1 notes .pdf
22519 - Client-Side Scripting Language (CSS) chapter 1 notes .pdf
 
Bangalore @ℂall @Girls ꧁❤ 0000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe
Bangalore @ℂall @Girls ꧁❤ 0000000000 ❤꧂@ℂall @Girls Service Vip Top Model SafeBangalore @ℂall @Girls ꧁❤ 0000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe
Bangalore @ℂall @Girls ꧁❤ 0000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe
 
Conservation of Taksar through Economic Regeneration
Conservation of Taksar through Economic RegenerationConservation of Taksar through Economic Regeneration
Conservation of Taksar through Economic Regeneration
 
Understanding Cybersecurity Breaches: Causes, Consequences, and Prevention
Understanding Cybersecurity Breaches: Causes, Consequences, and PreventionUnderstanding Cybersecurity Breaches: Causes, Consequences, and Prevention
Understanding Cybersecurity Breaches: Causes, Consequences, and Prevention
 
Online music portal management system project report.pdf
Online music portal management system project report.pdfOnline music portal management system project report.pdf
Online music portal management system project report.pdf
 
1239_2.pdf IS CODE FOR GI PIPE FOR PROCUREMENT
1239_2.pdf IS CODE FOR GI PIPE FOR PROCUREMENT1239_2.pdf IS CODE FOR GI PIPE FOR PROCUREMENT
1239_2.pdf IS CODE FOR GI PIPE FOR PROCUREMENT
 
Advances in Detect and Avoid for Unmanned Aircraft Systems and Advanced Air M...
Advances in Detect and Avoid for Unmanned Aircraft Systems and Advanced Air M...Advances in Detect and Avoid for Unmanned Aircraft Systems and Advanced Air M...
Advances in Detect and Avoid for Unmanned Aircraft Systems and Advanced Air M...
 
Software Engineering and Project Management - Introduction to Project Management
Software Engineering and Project Management - Introduction to Project ManagementSoftware Engineering and Project Management - Introduction to Project Management
Software Engineering and Project Management - Introduction to Project Management
 
UNIT I INCEPTION OF INFORMATION DESIGN 20CDE09-ID
UNIT I INCEPTION OF INFORMATION DESIGN 20CDE09-IDUNIT I INCEPTION OF INFORMATION DESIGN 20CDE09-ID
UNIT I INCEPTION OF INFORMATION DESIGN 20CDE09-ID
 

Progressive Enhancment with Rails and React

  • 2. My Name is Tyler Johnston
  • 3. What is Progressive Enhancement?
  • 4. Traditional development with Rails works great. Full page refreshes, static content, all HTML generation.
  • 5. But clients and customers want interactivity and performance.
  • 7. Keep your Rails workflow but add Javascript where it’s necessary.
  • 9. ails 4 it is now a default gem in the generated G
  • 10. ert your application in to a single page applica
  • 11. Download all of the Javascript and Stylesheets once and reuse for multiple page views.
  • 12. s. Turbolinks replaces the content of the <body
  • 13. Turbolinks gracefully falls back to browser defaults for POST/PUT/DELETE requests as well as the absence of Javascript.
  • 14. While Turbolinks provides lots of benefits there are a few caveats which caused a lot of developers to not use it.
  • 15. Turbolinks causes most requests to not yield a full page refresh. This means you must think differently about how you organize and handle your Javascript.
  • 16. Your application is now a long living Javascript application. You must be wary of memory leaks. This means ensuring no circular references and writing your Javascript in a way that allows for garbage collection when the controller changes actions.
  • 17. $(document).on('page:load', function() { // wire up javascript events for a page load }); $(document).on('page:before-unload', function() { // cleanup references from before });
  • 18. This means that just about every jQuery plugin you may find will cause memory leaks. Most of these plugins are poorly designed and with a fresh page load in mind. They don’t tend to track references or have a way to clean them up.
  • 19. al solutions to these problems that we’ve all tri
  • 20. if ($('.organization').length > 0) { $('.organization').each(function(index, element) { var $el = $(element); $.getJSON('/meetup/group/' + $el.prop('data-meetup-id'), function(data) { $el.find('a.title').prop('href', 'http://meetup.com/' + data.meetup_id) $el.find('a.title h1').html(data.title); $el.find('span.members').html(data.members_count); $el.find('img.meetup-logo').html(data.images.group_logo_large); }); }); }
  • 21. Now HTML is rendered by Rails and we have this pyramid of doom to update our content. What if we needed logic for different pieces? What if the Meetup API starts replying with varying data based on something in their state? What if we want to poll repeatedly for changes?
  • 22. We could move HTML rendering to templates and now we need another gem to precompile Handlebars/Jade/Haml Javascript templates. Even more logic going in to this single function.
  • 23. ot a good fit for this style of development. They
  • 24. Enter React React is the light-weight functional view layer from Facebook designed for building UIs with a focus on immutable data structures.
  • 25. React is designing your UI around reusable and self-contained components.
  • 26. No separation of files with controllers, views, templates and models. Allows for ease of maintainability for even the most of Javascript novices. React has a wonderfully simple API that will take 15 minutes to learn.
  • 28. var Organization = React.createClass({ componentWillMount: function() { $.getJSON('/meetup/group/' + this.props.meetup_id) .then(function(json) { this.setState(json); }.bind(this)); }, meetupURL: function(path) { return "http://www.meetup.com/" + this.props.meetup_id + path; }, render: function() { return <div> <OrganizationImage photos={this.state.group_photo} /> <OrganizationName name={this.state.name} meetupURL={this.meetupURL} /> <OrganizationEvent event={this.state.next_event} meetupURL={this.meetupURL} /> <OrganizationMembers members={this.state.members} meetupURL={this.meetupURL} /> </div>; } });
  • 29. React is designed around a one-way data flow. Views are considered to be immutable and state should be kept to single place. When state changes the views are created from scratch and render and all mutated state/properties are replaced.
  • 30. var Organization = React.createClass({ componentWillMount: function() { $.getJSON('/meetup/group/' + this.props.meetup_id).then(function(json) { this.setState(json); }.bind(this)); }, meetupURL: function(path) { return "http://www.meetup.com/" + this.props.meetup_id + path; }, render: function() { return <div> <OrganizationImage photos={this.state.group_photo} /> </div>; } }); var OrganizationImage = React.createClass({ render: function() { return <img src={this.props.photos.highres_link} width="80" height="80"/>; } });
  • 31. data. What about collecting data or doing things
  • 32. t unidirectional flow. Data goes down and eve
  • 33. why was the end of Lost so bad? SearchAutocomplete
  • 34. var SearchAutocomplete = React.createClass({ handleAutocomplete: function(event) { var query = event.target.value; this.setState({ searchQuery: query }); $.getJSON(this.props.autocompleteUrl, { q: query }) .then(function(autocompleteOptions) { this.setState({ options: autocompleteOptions }); }); }, render: function() { return <div> <SearchAutocompleteInput value={this.state.searchQuery} handleChange={this.handleAutocomplete} /> <SearchAutocompleteResults options={this.state.options} /> </div>; } });
  • 36. var SearchAutocomplete = React.createClass({ handleAutocomplete: function(event) { var query = event.target.value; this.setState({ searchQuery: query }); $.getJSON(this.props.autocompleteUrl, { q: query }) .then(function(autocompleteOptions) { this.setState({ options: autocompleteOptions }); }); }, render: function() { return <div> <SearchAutocompleteInput value={this.state.searchQuery} handleChange={this.handleAutocomplete} /> <SearchAutocompleteResults options={this.state.options} /> </div>; } });
  • 38. Whats with all the Javascript? Isn’t this about Rails?
  • 40. unctionality and dependencies of React while t
  • 42. <% @organizations.each do |organization| %> <%= react_component('Organization', organization.to_json) %> <% end %>
  • 43. Mounts the React component Sets the properties of the component from the given hash Automatically cleans up references and handles memory management with Turbolinks callbacks
  • 44. But what about SEO and search engine crawling?
  • 47. React knows how to pre-render using ExecJS so the component will boot using the existing HTML that is valid for React.
  • 48. I’ve come full circle on my thinking of front end development. Rails development feels better than every alternative, no matter how polished. React and React-Rails allows for a really great convergence of great and fast front end tooling with Rails fast development cycle.
  • 49. Go forth and try React with Rails! Questions? Comments?

Editor's Notes

  1. A lot of people were not happy with Turbolinks and most people remove it out of frustration.
  2. In this example we can see the state is contained to the “Organization” component. That is responsible for creating and passing data to the child views. When it is “mounted” it sends a network request.
  3. The child input isn’t even responsible for updating the state of the “value.” It is passed in after the searchQuery value changes.
  4. The child input isn’t even responsible for updating the state of the “value.” It is passed in after the searchQuery value changes.
  5. Testing works out of the box. Javascript unit testing works out of the box with `jasmine-rails`. JSX compilation with Sprockets works out of the box.