Has the removal of Javascript conditional compilation been confirmed in IE11?

I have been using javascript conditional compilation to determine the version of the IE Trident engine:

var ieVersion = undefined;
/*@cc_on
   ieVersion = Math.floor(@_jscript_version);
@*/

Despite working fine for IE8, 9, and 10, in IE11, the conditionally-commented block does not execute unless I use the F12 dev tools to emulate IE10. This discrepancy is confusing given that the MSDN page on conditional compilation specifies that it applies to Internet Explorer 11. (UPDATE 2015-02-03: this page has been updated to state that its content does not apply to IE11 in standards mode.) There isn't much information online indicating that IE11 should not support conditional comments.

If anyone has any insights or can reproduce this behavior in IE11, please share!


Edit: the issue revolves around IE's <audio> support. My web app requires playback of approximately 50 short (~1 sec) audio files in a random order individually after user interaction. However, there are various problems:

  • IE9 has an undocumented limit of 41 audio elements which causes subsequent audio files to fail silently. Re-assigning the source also fails every second time. The root cause behind these bugs remains unknown.
  • IE10 and IE11 experience stutter when playing short sounds - they play a fraction of a second then pause before continuing. This renders the audio unintelligible despite having preload="auto" and reported non-zero buffer.

Detecting these issues via feature detection is impractical, hence the browser-detect approach. Though user-agent sniffing may be risky for production code, the @cc_on technique seemed more reliable.

To workaround the issue in IE9, I serialize the app state to sessionStorage after the 25th sound, then reload the page and deserialize.

In IE10/11, my workaround involves playing the last 90% of the audio at 0 volume to force proper buffering.

Answer №1

It is confirmed that IE11 no longer supports JavaScript conditional compilation


A search on Google shows this question as the third result, following two MSDN pages which are also mentioned. This solidifies the credibility of this question and its comments being considered the main reference for the absence of Javascript conditional compilation in IE11.

I have given feedback to correct the information on the misleading MSDN pages.

Update 2015-02-03: The acknowledgement from MSDN now confirms that IE11 does not support @cc_on.


Here are a couple of workarounds:

User-agent detection

 /\([^)]*Trident[^)]*rv:([0-9.]+)/.exec(ua)

This snippet will extract the "revision number" at the end of IE11's User-Agent string.

ScriptEngineMajorVersion() (thanks @Teemu)

 var tridentVersion = 
     typeof ScriptEngineMajorVersion === "function" ?
         ScriptEngineMajorVersion() : undefined

Although this may work across all browsers, there is no guarantee that ScriptEngineMajorVersion will not be discontinued unexpectedly like conditional compilation.


Appreciation goes out to all the contributors.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Utilizing the Power of Magicline in Conjunction with Flexslider

Currently, I am implementing Flexslider for a slideshow on my website and I am attempting to integrate Magicline with it. The functionality is working well, but I have encountered an issue where the magicline does not move when clicking on the navigation a ...

The functionality of Change Detection is inconsistent when data is being received from the Electron Container IPC Channel

I have a program that is waiting for incoming information from an IPC Renderer Channel. Here is how I have it set up: container sending data to Angular app (mainWindow): mainWindow.loadURL('http://www.myangularapp.com') //location of the angul ...

Removing the Angular controller instance

To make things easier, the issue has been condensed under "The problem" for quick reference. For more details, continue reading for background information and notes before providing an answer. Thank you! The problem My goal is to remove the instance of a ...

I've encountered a peculiar error that is new to me while using bootstrap and javascript. Can anyone shed light on what this error signifies?

Hey there! I've come across this error in the console while attempting to utilize Bootstrap. It seems that a style is being refused from 'http://127.0.0.1:5500/node_modules/font-awesome/css/font-awesome.min.css' due to its MIME type ('t ...

Optimal management using an image and an onClick event to trigger a JavaScript function

Which control stands out as the optimal choice for displaying images, executing JavaScript functions without postback, and possibly even changing images on hover? ...

When using the RxJs Pipe with MAP in Angular and Ionic, it may not return a value in windows, but it works perfectly in Mac when used with HttpClient

I'm currently using RxJs Pipe with Map for a network request in my Angular/Ionic project. Interestingly, while I do receive a successful response in the network log, the MAP function fails to return any value. Notable Observations Strangely, this fu ...

Two draggable elements and two droppable containers all conveniently placed on a single webpage

My current project involves two sets of draggable elements and two sets of droppable elements. I'm trying to achieve a specific functionality where the first set of draggable elements can only be dropped inside the first set of droppables, while the ...

I am looking to consolidate my array of objects into a single object with distinct keys

Hey there! I'm looking to showcase the expenses for each category throughout the months of the year. Here's an example: {Month: "January", Food: 610, foodColor: "#063951", Others: 121, othersColor: "#C13018", …} Fo ...

What is the best way to observe a function and provide a simulated result from within a different function using jasmine?

Query: How can I access the reference of getWindowSize within getBreakpoint() to perform spying on it? Additionally, how can I use callFake to return mock data? media-query.ts export const widthBasedBreakpoints: Array<number> = [ 576, 768, 99 ...

What is the reason behind the NextJS logo not being displayed when accessing the page via its URL?

My logo isn't displaying on the /page URL View Screenshot Check out my components/LayoutWrapper.js import Image from 'next/image' import icon from '../assets/images/Icon.svg' <div className="flex items-ce ...

retrieving the current value of a variable from a jQuery function

I've done my best to keep things simple. Here's the HTML code I've put together: <div id="outsideCounter"><p></p></div> <div id="clickToAdd"><p>Click me</p></div> <div id="in ...

What is the best way to store objects containing extensive binary data along with additional values?

I'm currently working on saving a JavaScript object that includes binary data along with other values. I want the output to resemble the following: { "value":"xyz", "file1":"[FileContent]", "file2&quo ...

Drop and drag to complete the missing pieces

Here is a drag and drop fill in the blanks code I created. The challenge I'm facing is that I want users to be able to correct their mistakes by moving words to the right place after receiving points. <!DOCTYPE HTML> <html> <head&g ...

How to prevent click events and still enable scrolling within a DIV using CSS/JS

Basically, I am looking to enable scrolling within a DIV while also disabling click events. Any suggestions on how this can be achieved? Appreciate any help! ...

Why isn't the onChange function triggering in the input type text when the input is not manually typed in?

I am currently facing an issue with two text fields in my HTML form. Here is how they are set up: HTML : <input type="text" id="input1" onchange="doSomething();" disabled/> <input type="text" id="input2"/> JavaScript : function doSomething( ...

Step-by-Step Guide: Crafting a Non-Ajax Popup Chat Application

Recently, I created a unique dating website with a one-to-one chat feature similar to Facebook. However, I implemented this using the ajax technique and the setInterval function in JavaScript for regular updates. Upon reflection, I believe that this appr ...

Linking a variable in typescript to a translation service

I am attempting to bind a TypeScript variable to the translate service in a similar way as binding in HTML markup, which is functioning correctly. Here's what I have attempted so far: ngOnInit() { this.customTranslateService.get("mainLayout.user ...

Expanding the default Stackblitz App component with additional standalone Angular components?

I have recently developed a separate AppNavComponent component on Stackblitz platform. import { Component } from '@angular/core'; import { CommonModule } from '@angular/common'; import { RouterOutlet } from '@angular/router'; ...

The form dropdowns are failing to reset after the select id is added in the html code

I'm attempting to reset the form fields. I have two selects with Select2 in JavaScript. If I eliminate the id of either select, it will reset, otherwise it will remain the same. $(document).ready(function() { $("#fieldName").select2(); $("#acti ...

What steps can be taken to stop the page from refreshing and losing its state when cancelling navigation using the back and forward browser buttons in React-router v4.3?

I'm currently facing an issue with a page in which user inputs are saved using a react context object. The problem arises when a user navigates away from the page without saving their entries. I want to prompt the user to either continue or cancel, wh ...