To do that, we need 2 things:
- Add code to that file containing Intellisense
So let's get started.
Add a .js file to the global references
First of all, we must create a .js file somewhere on disk. Potentially on a network share for your entire team, or just in the user's documents folder. It doesn't matter where.
Then add a reference to it in Tools -> Options like this:
Make sure to chose Implicit (Web) in the Reference Group dropdown. Otherwise it won't take effect for web projects.
Write some Intellisense
Let's start by adding support for the new HTML Imports API. It's really simple because it only adds a single new property to DOM elements called import. So an example of how to use it would be something like this:
var link = document.querySelector('link[rel=import]'); var partial = link.import;
The value of partialis a Document element just like window.document. To add Intellisense for the import property, simple add this one line to your Intellisense .js file:
Element.prototype.import = Document.prototype;
What I've found to be a good rule of thumb is to make the added Intellisense apply more broadly than the spec might call for. In the example above, the import property should only apply to <link> elements (HTMLLinkElement), but since VS can't always know what type of element you're referencing, it makes good sense to just make it apply to all elements. It's up to you of course, but I think that this makes for a better experience.
The issue is that Web Essentials can't always add those two files to the global references.
If you already have Web Essentials installed, then you already have these two files located in C:\users\yourname\.
The files are:
If not, just add them in the above dialog. The APIs that are added through Web Essentials are:
- Shadow DOM
- Vibration API
- Fullscreen API
- Canvas (improvements)
- Server-Sent Events
- HTML Imports
As an added bonus, all of this also applies to Visual Studio 2012, but you have to get the two .js files from Web Essentials 2013 manually since they aren't shipped with Web Essentials 2012.