How can I add default preview for files in Explorer?

Follow these directions to edit the Registry and assign the Windows Text Preview Handler to the .js file extension. (Based on this How To Geek article.)

  1. Open Registry Editor
  2. Navigate to HKEY_CLASSES_ROOT\.js and make note of the content of the (Default) value. This is the ProgID to which the .js extension is registered: enter image description here
  3. Navigate to the ProgID's key. We'll find our key at HKEY_CLASSES_ROOT\JSFile
  4. Expand the key. If necessary, create a subkey named ShellEx
  5. Under the ShellEx key, create a new key named {8895b1c6-b41f-4c1c-a562-0d564250836f}. Note: According to MSDN the presence of this exact value tells Windows that this is a preview handler.
  6. Select this newly created key and set its (Default) value to {1531d583-8375-4d3f-b5fb-d23bbd169f22}. This is the ID for Windows' Text Preview Handler. enter image description here
  7. The change will take effect immediately.

Since the file contents are just plain text, you can make Explorer treat it as such. You can use Content Type and PerceivedType to achieve that. Here is how to do it:

  1. In the Registry Editor, navigate to the key related to that file type. For the file type asked, the path would be like HKEY_CLASSES_ROOT\.js.
  2. In that key, right-click the right panel and choose New > String Value.
  3. Name it as Content Type.
  4. Double click that value and set it as text/plain.
  5. Right-click the right panel and choose New > String Value.
  6. Name it as PerceivedType.
  7. Double click that value and set it as text.

Restart Explorer and voilá! The file will still be associated with any editor you have set but the built-in preview feature will treat it as a text file and then show a preview.

As a side effect, if you sort/group your list in Explorer as Perceived Type it will be classified under Text file.

Note: for instance I did a test by making a .dummy and associated it with Google Chrome, the file could be previewed in the Preview Pane and double-clicking it still executed Chrome as intended.