concept script in category javascript

This is an excerpt from Manning's book JavaScript on Things: Hacking hardware for web developers.
Instead of repeatedly booting from the SD card, what you want to do is flash the OS image to the onboard eMMC flash storage. This requires an additional, slightly finicky, step here: a configuration file needs a simple edit. After you flash the SD card with the Debian image, it may not be readable by your computer (it wasn’t with mine). Instead, you can go ahead and boot the BeagleBone Black directly from the SD card, once, so that you can edit that config file:
- Insert the microSD card with the Debian image on it into the BeagleBone Black.
- Connect the BeagleBone Black directly to your router with an Ethernet cable, and then plug in power to the BeagleBone Black. It’ll take a minute or two for the BeagleBone Black to boot up and get an IP address on your network.
- Fire up your LAN- or IP-scanning utility to figure out the BeagleBone Black’s IP address.
- From your computer, in a terminal, ssh into the BBB with the debian user (ssh is enabled by default in the Debian image you’re using here):
There’s a default password for that user, which will be displayed to you on first login.$ ssh debian@<BBB IP>- Edit the configuration file in question:
(or use your preferred editor if you don’t like vi). Toward the bottom of the file, find the following line and uncomment it (remove the #):$ sudo vi /boot/uEnv.txtSave and exit the file. Uncommenting that line will allow the BeagleBone Black to run a script on startup that will copy (flash) the contents of the SD card to the built-in eMMC.#cmdline=init=/opt/scripts/tools/eMMC/init-eMMC-flasher-v3.sh
Define a script to start the app (in package.json).

This is an excerpt from Manning's book Secrets of the JavaScript Ninja, Second Edition.
When Bob was first learning web development, each browser had its own way of interpreting script and UI styles, preaching that their way was the best way and making every developer grind their teeth in frustration. Fortunately, the browser wars ended with HTML, CSS, the DOM API, and JavaScript all being standardized, and developer focus turning toward effective cross-browser JavaScript applications. Indeed, this focus on treating websites as applications led to many ideas, tools, and techniques crossing over from desktop applications to web applications. And now, that knowledge and tools transfer has happened again as ideas, tools, and techniques that originated in client-side web development have also permeated other application domains.
Not doing so can cause unexpected results, because the script attempts to access the as-yet-undefined style information. Unfortunately, this issue can’t easily be rectified with pure JavaScript and should instead be handled with user documentation.

This is an excerpt from Manning's book Third-Party JavaScript.
On the web, you might think of the first party as a user who’s operating a web browser. When they visit a web page, the browser makes a request from a content provider. That provider, the second party, transmits the web page’s HTML, images, stylesheets, and scripts from their servers back to the user’s web browser.
Remember: your goal is to serve a script from your servers and have it loaded on a publisher’s website. So to re-create that scenario, you’ll need to have a test page to simulate a publisher’s website and a web server to serve your script from. You’ll also need both the test page and script files served from different domains.
Here’s how the script include snippet looks using dynamic <script> tag insertion.
Let’s discuss some interesting points about this example. You’ll notice that the script element’s async attribute is set to true. This isn’t just for posterity—Opera and some older versions of Firefox require this attribute to be set in order for the script to be executed as soon as it is downloaded. Otherwise, Opera and Firefox will attempt to preserve execution order (similar to the defer attribute). Second, you’ll notice that this entire snippet is wrapped in an immediately-invoked function expression, or IIFE. This prevents the script and entry variables from leaking into the global scope. Remember: this code snippet is executing on the publisher’s page, which could be home to any number of additional, unknown scripts. It’s best to avoid declaring global variables, which could interfere with—or be interfered with by—other JavaScript code.
Let’s start with the basics. You should already be familiar with how to load scripts using the standard HTML <script> tag. Using it to load your initial script file is straightforward: just give publishers a standard <script> tag to paste into their HTML source code whose src attribute points to your JavaScript file. This is the simplest, smallest amount of code you could give to your publishers. If you recall, we used this in chapter 1 in the weather widget example.
One way to limit the effect of blocking scripts is to advise publishers to place the script include at the end of their HTML source. That way, if your script is slow, it won’t matter (as much) because the browser has already rendered the page. The downside is that you can’t rely on the script element’s position in the DOM to determine where to render your widget. But you can always ask publishers to identify the target render location separately using a uniquely identified element:
<body> <div id="camerastork-widget"/> <p>Hello, world</p> <script src="http://camerastork.com/widget.js?product=1234"></script> </body>In this example, when widget.js loads, it’ll render the product widget and append it to the <div> element with id="camerastork-widget". From a performance perspective, this is better than the earlier script include, because it doesn’t block the publisher’s page (although the total load time will be about the same). But this is contingent on the publisher correctly placing the script include at the end of their HTML source. And experience tells us this isn’t always a given.

This is an excerpt from Manning's book Prototype and Scriptaculous in Action.
If the history of Ajax began with Garrett’s article in 2005, then the discipline has a rich prehistory, in which the techniques behind Ajax were being explored without a name around which to rally the various practitioners. Ajax was first made possible by the invention of an ActiveX component called XMLHttpRequest. This component allowed web applications to contact the web server without refreshing the entire page, but rather passing the response to a script for processing. These hidden requests for data are generally referred to as asynchronous, a term that provides the first “A” in Ajax. Browsers had long been able to manipulate the user interface programmatically using the Document Object Model (DOM) and CSS, but without the ability to fetch anything new from the server; full-page refreshes were still frequent. Adding XMLHttpRequest into the mix made it possible for an entire application workflow to be encapsulated within a single web page, which simply reorganized itself in response to asynchronous requests for data made while the user was working.
The code we’ve presented so far is admirably simple, but we have a problem. When we navigate to a new folder, we need to update the breadcrumb trail, the subfolders list, and the thumbnails. We’ve laid these out as three separate DOM elements on the page, but so far we’ve only updated one of them. The limitation of Ajax.Updater without evaluating scripts in the response is that the class updates only one element in an Ajax request.