Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
ECMAScript Cookbook
ECMAScript Cookbook

ECMAScript Cookbook: Over 70 recipes to help you learn the new ECMAScript (ES6/ES8) features and solve common JavaScript problems

eBook
€8.99 €26.99
Paperback
€32.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

ECMAScript Cookbook

Building with Modules

 In this chapter, we will cover the following recipes:

  • Installing and configuring browsers—Chrome and Firefox
  • Installing Python, using SimpleHTTPServer to host a local static file server
  • Creating an HTML page that loads an ECMAScript module
  • Exporting/importing multiple modules for external use
  • Renaming imported modules
  • Nesting modules under a single namespace

Introduction

JavaScript is the most famous language that adheres to the ECMAScript standard. This standard was created in the late 1990s in order to guide the development of the language. In the early years, development was slow, with only four major versions reaching production in the first two decades. However, with increased exposure, largely thanks to the popularization of the Node.js run-time, the pace of development has increased dramatically. The years 2015, 2016, and 2017 each saw new releases of the of the standard, with another planned for 2018.

With all these developments, now is an exciting time to be a JavaScript developer. A lot of new ideas are coming in from other languages, and the standard API is expanding to be more helpful. This book focuses on new features and techniques that can be used in the newer versions of JS as well as future versions!

Historically, creating JavaScript programs that span multiple files has been a painful experience. The simplest approach was to include each of the files in separate <script> tags. This also requires developers to position the tags in the correct order.

Various libraries have attempted to improve this situation. RequireJS, Browserfy, and Webpack all attempt to solve the problem of JavaScript dependencies and module loading. Each of these requires some kind of configuration or build step.

The situation has improved in recent years. Browser manufacturers collaborate in creating the ECMAScript specification. It is then up to the manufacturers to implement JavaScript interpreters (programs that actually run the JavaScript) that adhere to that specification

New versions of browsers are being released that support native ECMAScript modules. ECMAScript modules provide an elegant method for including dependencies. Best of all, unlike the previous methods, modules don't require any build step or configuration.

The recipes in this chapter focus on installing and configuring the Chrome and Firefox  web browsers and how to take full advantage of ES modules and the import/export syntax.

Installing and configuring - Chrome

Subsequent recipes will assume an environment that is capable of using ES modules. There are two strategies for accomplishing this: creating a build step that collects all the modules used into a single file for the browser to download, or using a browser that is capable of using ES modules. This recipe demonstrates the latter option.

Getting ready

To step through this recipe, you need a computer with an operating system (OS) that is supported by Chrome (not Chromium). It supports recent versions of Windows and macOS, as well as a large number of Linux distributions. Most likely, if your OS doesn't support this browser, you are already aware of this.

How to do it...

  1. To download Chrome, navigate your browser to the following:
    https://www.google.co.in/chrome/.
  2. Click Download and accept the terms of service.
  3. After the installer finishes downloading, double-click the installer to launch it and follow the onscreen instructions.
  1. To check the version of Chrome, open the Chrome browser, and enter the following URL:  
    chrome://settings/help.
  2. You should see the Version number where the number is 61 or higher. See the following screenshot:

How it works...

The current versions of Chrome come with ES modules enabled out of the box. So no configuration or plugins are required to get them working!

There's more...

At the time of writing, only a few browsers support ECMAScript. You can see which browsers support modules under the Browser compatibility section of the page at https://mzl.la/1PY7nnm.

Installing and configuring - Firefox

Subsequent recipes will assume an environment that is capable of using ES modules. There are two strategies for accomplishing this: creating a build step that collects all the modules used into a single file for the browser to download, or using a browser that is capable of using ES modules. This recipe demonstrates the latter option.

Getting ready

To step through this recipe, you need a computer with an operating system (OS) that is supported by Firefox. It supports recent versions of Windows and macOS, as well as a large number of Linux distributions. Most likely, if your OS doesn't support Firefox, you are already aware of this.

How to do it...

  1. To install Firefox, open a browser and enter the following URL:
    https://www.mozilla.org/firefox.
  2. Click the button that says Download to download the installer.
  3. After the installer has finished downloading, double click the installer and follow the onscreen instructions.
  4. To configure Firefox, open the Firefox browser and enter the following URL: 
    about:config.
  5. The menu will allow you to enable advanced and experimental features. If you see a warning, click the button that says I accept the risk!
  6. Find the dom.moduleScripts.enabled setting, and double-click it to set the value to true, as shown in following screenshot:

How it works...

Firefox supports ES modules, but disables them by default. This allows developers to experiment with the feature, while the majority of users are not exposed to it.

There's more...

The same as the Installing and configuring - Chrome section.

Installing Python, using SimpleHTTPServer to host a local static file server

It is possible to browse web pages directly from the filesystem. However, Chrome and Firefox have security features that make this inconvenient for development. What we need is a simple static file server. This recipe demonstrates how to install Python (if necessary) and use it to serve files from a directory.

Getting ready

Find out how to open the command line on your OS. On macOS and Linux, this is called the Terminal. On Windows, it is called the Command Prompt.

You should use a browser that is configured to load ES modules (see the first recipe).

How to do it...

  1. Check whether you have Python installed already.
  2. Open the command line.
  3. Enter the following command:
python --version
  1. If you see an output like the one displayed as follows, Python is already installed. And you can skip to step 6:
Python 2.7.10
  1. If you receive an error such as the following, continue with the installation in step 5:
command not found: python
  1. Install Python on your computer:
  2. Create a folder on your desktop named es8-cookbook-workspace.
  3. Inside the folder, create a text file named hello.txt and save some text to it.
  4. Open the Command Prompt and navigate to the folder:
  5.  In the Linux or macOS Terminal enter:
    cd ~/Desktop/es8-cookbook-workspace
  1. On Windows type the following command:
    cd C:Desktopes8-cookbook-workspace 
  1. Start the Python HTTP server with the following command:
    python -m SimpleHTTPServer # python 2 

Or we can use following command:

python -m http.server # python 3
  1. Open your browser and enter the following URL:
    http://localhost:8000/.
  1. You should see a page that shows the contents of the es8-cookbook-workspace folder:
  1. Click on the link to hello.txt and you'll see the text contents of the file you created.

How it works...

The first thing we did was check if Python was installed. The best way to do this is to ask Python for its version number. This way we know whether Python is installed, and if it's new enough for our purposes.

If it's not installed, Python can be retrieved via the OS's package manager, or via the installers made available through Python's website.

Once installed, Python comes with a lot of utilities. The one we are interested in is the appropriately named SimpleHTTPServer. This utility listens for HTTP requests on port 8000, and returns the contents of the files relative to the directory root. If the path points to a directory, it returns an HTML page that lists the directory contents.

Creating an HTML page that loads an ECMAScript module

In previous recipes, we went over installation and configurations instructions to run a static file server using Python and configure a browser to use ES modules.

Getting ready

This recipe assumes that you have the static file server running in your working directory. If you haven't installed Python or configured your browser to work with ES modules, please see the first two recipes in the book.

The following steps will demonstrate how to create an ES module and load it into an HTML file.

How to do it...

  1. Create an hello.html file with a some text content:
<html>
<meta charset="UTF-8" />
<head>
</head>
<body>
Open Your Console!
</body>
</html>
  1. Open hello.html by opening your browser, and entering the following URL:  http://localhost:8000/hello.html.
  1. You should see Open Your Console! displayed by the browser:

  1. Lets do what the page tells us and open up the Developer Console. For both Firefox and Chrome, the command is the same:
    • On Windows and Linux:
Ctrl + Shift + I 
  • On macOS:
Cmd + Shift + I  
  1. Next, in the same directory, create a file called hello.js, which exports a function named sayHi that writes a message to the console:
// hello.js 
export function sayHi () { 
  console.log('Hello, World'); 
} 
  1. Next add a script module tag to the head of hello.html that imports the sayHi method from hello.js (pay attention to the type value).
  1. Reload the browser window with the Developer Console open and you should see the hello message displayed as text:

How it works...

Although our browser can work with ES modules, we still need to specify that is how we want our code to be loaded. The older way of including script files uses type="text/javascript". This tells the browser to execute the content of the tag immediately (either from tag contents or from the src attribute).

By specifying type="module", we are telling the browser that this tag is an ES module. The code within this tag can import members from other modules. We imported the function sayHi from the hello module and executed it within that <script> tag. We'll dig into the import and export syntax in the next couple of recipes.

See also

  • Exporting/importing multiple modules for external use
  • Adding fallback script tags

Exporting/importing multiple modules for external use

In the previous recipe, we loaded an ES module into an HTML page and executed an exported function. Now we can take a look at using multiple modules in a program. This allows us more flexibility when organizing our code.

Getting ready

Make sure you have Python installed and your browser properly configured.

How to do it...

  1. Create a new working directory, navigate into it with your command-line application, and start the Python SimpleHTTPServer.
  2. Create a file named rocket.js that exports the name of a rocket, a countdown duration, and a launch function:
export default name = "Saturn V"; 
export const COUNT_DOWN_DURATION = 10; 
 
 
export function launch () { 
  console.log(`Launching in ${COUNT_DOWN_DURATION}`); 
  launchSequence(); 
} 
 
function launchSequence () { 
  let currCount = COUNT_DOWN_DURATION; 
 
  const countDownInterval = setInterval(function () { 
    currCount--; 
 
    if (0 < currCount) { 
      console.log(currCount); 
    } else { 
      console.log('LIFTOFF!!! '); 
      clearInterval(countDownInterval); 
    } 
  }, 1000); 
}
  1. Create a file named main.js that imports from rocket.js, logs out details, and then calls the launch function:
import rocketName, {COUNT_DOWN_DURATION, launch } from './rocket.js'; 
 
export function main () { 
  console.log('This is a "%s" rocket', rocketName); 
  console.log('It will launch in  "%d" seconds.', COUNT_DOWN_DURATION); 
  launch(); 
} 
  1. Next, create an index.html file that imports the main.js module and runs the main function:
<html> 
  <head> 
    <meta charset='UTF-8' /> 
  </head> 
  <body> 
    <h1>Open your console.</h1> 
    <script type="module"> 
      import { main } from './main.js'; 
      main(); 
    </script> 
  </body> 
</html> 
  1. Open your browser and then the index.html file. You should see the following output:

How it works...

There are two options for exporting a member from a module. It can either be exported as the default member, or as a named member. In rocket.js, we see both methods:

export default name = "Saturn V"; 
export const COUNT_DOWN_DURATION = 10; 
export function launch () { ... } 

In this case, the string "Saturn V" is exported as the default member, while COUNT_DOWN_DURATION and launch are exported as named members. We can see the effect this has had when importing the module in main.js:

 import rocketName, { launch, COUNT_DOWN_DURATION } from './rocket.js'; 

We can see the difference in how the default member and the name members are imported. The name members appear inside the curly braces, and the name they are imported with matches their name in the module source file. The default module, on the other hand, appears outside the braces, and can be assigned to any name. The unexported member launchSequence cannot be imported by another module.

See also

  • Renaming imported modules
  • Nesting imported modules under a single namespace

Renaming imported modules

Modules allow more flexibility in organizing code. This allows for a shorter, more contextual name. For example, in the previous recipe, we named a function launch instead of something more verbose such as launchRocket. This helps keep our code more readable, but it also means that different modules can export members that use the same name.

In this recipe, we'll rename imports in order to avoid these namespace collisions.

Getting ready

We'll be reusing the code from the previous recipe (Exporting/importing multiple modules for external use). The changes from the previous files will be highlighted.

How to do it...

  1. Copy the folder created for the previous recipe into a new directory.
  2. Navigate to that directory with your command-line application and start the Python server.
  1. Rename rocket.js to saturn-v.js, add the name of the rocket to the log statements, and update the main.js import statement:
// main.js 
import name, { launch, COUNT_DOWN_DURATION } from './saturn-v.js'; 
 
export function main () { 
  console.log('This is a "%s" rocket', name); 
  console.log('It will launch in  "%d" seconds.', COUNT_DOWN_DURATION); 
  launch(); 
} 
// saturn-v.js export function launch () { console.log(`Launching %s in ${COUNT_DOWN_DURATION}`, name); launchSequence(); } function launchSequence () { // . . . console.log(%shas LIFTOFF!!!', name); // . . . }
  1. Copy saturn-v.js to a new file named falcon-heavy.js and change the default export value and the COUNT_DOWN_DURATION:
    export default name = "Falcon Heavy";
    export const COUNT_DOWN_DURATION = 5;  
  1. Import the falcon module into main.js. Rename the imported members to avoid conflicts and launch the falcon rocket as well:
import rocketName, { launch, COUNT_DOWN_DURATION } from './saturn-v.js'; 
import falconName, { launch as falconLaunch, COUNT_DOWN_DURATION as falconCount } from './falcon-heavy.js'; 
 
export function main () { 
  console.log('This is a "%s" rocket', rocketName); 
  console.log('It will launch in  "%d" seconds.', COUNT_DOWN_DURATION); 
  launch(); 
   
  console.log('This is a "%s" rocket', falconName);  console.log('It will launch in  "%d" seconds.', falconCount);  falconLaunch(); 
} 
  1. Open index.html in your browser and you should see the following output:

How it works...

When we duplicated the saturn-v.js file to and imported the members from falcon-heavy.js, we had a potential namespace conflict. Both files export members named COUNT_DOWN_DURATION and launch. But using the as keyword, we renamed those members in order to avoid that conflict. Now the importing main.js file can use both sets of members without issue.

Renaming members can also be helpful to adding context. For example, it might be useful to rename the launch as launchRocket even if there is no conflict. This give the importing module additional context, and makes the code a bit clearer.

Nesting modules under a single namespace

As the number of modules grows, patterns start to emerge. For practical and architectural reasons, it makes sense to group multiple modules together and use them as a single package.

This recipe demonstrates how to collect multiple modules together and use them as a single package.

Getting ready

It will be helpful to have the source code available from previous recipes to bootstrap this recipe. Otherwise, you'll need to reference Exporting/importing multiple modules for external use for how to create the index.html file.

How to do it...

  1. Create a new folder with an index.html file, as seen in Exporting/importing multiple modules for external use.
  2. Inside of that directory, create a folder named rockets.
  3. Inside of rockets, create three files: falcon-heavy.js, saturn-v.js, and launch-sequence.js:
// falcon-heavy.js 
import { launchSequence } from './launch-sequence.js'; 
 
export const name = "Falcon Heavy"; 
export const COUNT_DOWN_DURATION = 5; 
 
export function launch () { 
  launchSequence(COUNT_DOWN_DURATION, name); 
} (COUNT_DOWN_DURATION); 
} 
 
// saturn-v.js 
import { launchSequence } from './launch-sequence.js'; 
 
export const name = "Saturn V"; 
export const COUNT_DOWN_DURATION = 10; 
 
export function launch () { 
  launchSequence(COUNT_DOWN_DURATION, name); 
} 
 
// launch-sequence.js 
export function launchSequence (countDownDuration, name) { 
  let currCount = countDownDuration; 
  console.log(`Launching in ${COUNT_DOWN_DURATION}`, name); 
 
  const countDownInterval = setInterval(function () { 
    currCount--; 
 
    if (0 < currCount) { 
      console.log(currCount); 
    } else { 
      console.log('%s LIFTOFF!!! ', name); 
      clearInterval(countDownInterval); 
    } 
  }, 1000); 
} 
  1. Now create index.js, which exports the members of those files:
import * as falconHeavy from './falcon-heavy.js'; 
import * as saturnV from './saturn-v.js'; 
export { falconHeavy, saturnV }; 
  1. Create a main.js file (in the folder that contains rockets), which imports falconHeavey and saturnV from the index.js file and launches them:
import { falconHeavy, saturnV } from './rockets/index.js' 
 
export function main () { 
  saturnV.launch(); 
  falconHeavy.launch(); 
} 
  1. Open in the browser, and see the following output:

How it works...

The * syntax seen on the first two lines of index.js imports all the exported members under the same object. This means that the name, COUNT_DOWN_DURATION, and launch members of falcon-heavey.js are all attached to the falconHeavy variable. Likewise, for the saturn-v.js modules and the saturnV variable. So, when falconHeavy and saturnV are exported on line 4, those exported names now contain all the exported members of their respective modules.

This provides a single point where another module (main.js in this case) can import those members. The pattern has three advantages. It is simple; there is only one file to import members from, rather than many. It is consistent, because all packages can use an index module to expose members of multiple modules. It is more flexible; members of some modules can be used throughout a package and not be exported by the index module.

There's more...

It is possible to export named items directly. Consider the following file, atlas.js:

import { launchSequence } from './launch-sequence.js'; 
 
const name = 'Atlas'; 
const COUNT_DOWN_DURATION = 20; 
 
export const atlas = { 
  name: name, 
  COUNT_DOWN_DURATION: COUNT_DOWN_DURATION, 
  launch: function () { 
    launchSequence(COUNT_DOWN_DURATION, name); 
  } 
}; 

The atlas member can be exported directly by index.js:

import * as falconHeavy from './falcon-heavy.js'; 
import * as saturnV from './saturn-v.js'; 
 
export { falconHeavy, saturnV }; 
export { atlas } from './atlas.js';

Then the main.js file can import the atlas member and launch it:

import { atlas, falconHeavy, saturnV } from './rockets/index.js' 
 
export function main () { 
  saturnV.launch(); 
  falconHeavy.launch(); 
  atlas.launch(); 
} 

This is one benefit of always using named exports; it's easier to collect and export specific members from packages with multiple modules.

Whether named or not, nesting is a great technique for grouping modules. It provides a mechanism for organizing code as the number of modules continues to grow.

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Learn to write asynchronous code and improve the readability of your web applications
  • Explore advanced concepts such as closures, Proxy, generators, Promise, async functions, and Atomics
  • Use different design patterns to create structures to solve common organizational and processing issues

Description

ECMAScript Cookbook follows a modular approach with independent recipes covering different feature sets and specifications of ECMAScript to help you become an efficient programmer. This book starts off with organizing your JavaScript applications as well as delivering those applications to modem and legacy systems. You will get acquainted with features of ECMAScript 8 such as async, SharedArrayBuffers, and Atomic operations that enhance asynchronous and parallel operations. In addition to this, this book will introduce you to SharedArrayBuffers, which allow web workers to share data directly, and Atomic operations, which help coordinate behavior across the threads. You will also work with OOP and Collections, followed by new functions and methods on the built-in Object and Array types that make common operations more manageable and less error-prone. You will then see how to easily build more sophisticated and expressive program structures with classes and inheritance. In the end, we will cover Sets, Maps, and Symbols, which are the new types introduced in ECMAScript 6 to add new behaviors and allow you to create simple and powerful modules. By the end of the book, you will be able to produce more efficient, expressive, and simpler programs using the new features of ECMAScript. ?

Who is this book for?

If you’re a web developer with a basic understanding of JavaScript and wish to learn the latest features of ECMAScript for developing efficient web applications, this book is for you.

What you will learn

  • • Organize JavaScript programs across multiple files, using ES modules
  • • Create and work with promises using the Promise object and methods
  • • Compose async functions to propagate and handle errors
  • • Solve organizational and processing issues with structures using design patterns
  • • Use classes to encapsulate and share behavior
  • • Orchestrate parallel programs using WebWorkers, SharedMemory, and Atomics
  • • Use and extend Map, Set, and Symbol to work with user-defined classes and simulate data types
  • • Explore new array methods to avoid looping with arrays and other collections

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Mar 30, 2018
Length: 348 pages
Edition : 1st
Language : English
ISBN-13 : 9781788628174
Languages :
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Mar 30, 2018
Length: 348 pages
Edition : 1st
Language : English
ISBN-13 : 9781788628174
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 102.97
ECMAScript Cookbook
€32.99
Vue.js 2 Design Patterns and Best Practices
€36.99
Learn ECMAScript
€32.99
Total 102.97 Stars icon
Banner background image

Table of Contents

13 Chapters
Building with Modules Chevron down icon Chevron up icon
Staying Compatible with Legacy Browsers Chevron down icon Chevron up icon
Working with Promises Chevron down icon Chevron up icon
Working with async/await and Functions Chevron down icon Chevron up icon
Web Workers, Shared Memory, and Atomics Chevron down icon Chevron up icon
Plain Objects Chevron down icon Chevron up icon
Creating Classes Chevron down icon Chevron up icon
Inheritance and Composition Chevron down icon Chevron up icon
Larger Structures with Design Patterns Chevron down icon Chevron up icon
Working with Arrays Chevron down icon Chevron up icon
Working with Maps and Symbols Chevron down icon Chevron up icon
Working with Sets Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.3
(3 Ratings)
5 star 66.7%
4 star 0%
3 star 33.3%
2 star 0%
1 star 0%
Amazon Customer Sep 28, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Very informative writing! Great book!
Amazon Verified review Amazon
Angel Martínez May 21, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Casi diría excelente. Muy bien explicado y maquetado, con ejemplos prácticos y como dirían algunos "currado". Espero que las editoriales españolas aprendan como hacer un buen libro. Mucho me temo que no lo harán.
Amazon Verified review Amazon
YouCanHandleMyTruth May 16, 2018
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
It's ok. Gives you some concrete examples but I felt like there needed to be some my why's and now how.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.