ByLouis Peitzman,
a freelance writer who covers TV, film, and theater.
Photo: Universal Pictures
Take it from Fiyero: “Life is fraught-less when you’re thoughtless.” While the Wizard of Oz prequel tells a reasonably compelling story — albeit a much safer one than the Gregory Maguire novel the show is based on — we’re here to dance through the songs. There are 11 in the first act of the hit Broadway musical, so that’s exactly how many there are in Wicked (Part One). (That this is merely half the story is another thing the film’s early marketing may have been a bit cagey about.)
Yes, they’re all here, from showstoppers like “The Wizard and I” and “Defying Gravity” to traditional album skips like “Something Bad” and “A Sentimental Man.” As in his 2021 stage-to-screen adaptation of In the Heights, director Jon M. Chu shows real skill in putting together big production numbers, but he’s also got some tricks up his sleeve. Some of the movie’s best musical moments happen when Chu finds a new cinematic language to filter them through. At the same time, it’s easy for certain songs to get lost amid the scope and grandeur of the $145 million production.
It’s not exactly controversial to say that there are highs and lows to Stephen Schwartz’s Wicked score — with apologies to the skips mentioned above. Identifying the best and worst musical numbers in the movie won’t come as much of a surprise to anyone who knows the show. But to put together this ranking, I tried to look at the big picture, including the performances, the staging, the visuals, and, perhaps most importantly, how many times the song made me think, Okay, they ate that.
11.
“A Sentimental Man”
Look, Jeff Goldblum was not hired for his singing voice, which is basically fine. The Wizard’s bigger song is in Act II (er, Wicked Part Two) anyway, so we can rest easy until then. “A Sentimental Man” is barely a full number, most notable for one of my favorite “you’re not gonna get away with this, Stephen Schwartz” rhymes: “And helping you with your ascent / Allows me to feel so parental” (but you have to sing “ascental” to make it work).
In the film, we do get the Wizard dancing around his neat little Oz model, and that’s fun. My biggest issue with “A Sentimental Man” is that Goldblum is too much of a character in his own right to ever let you fully believe him as the Wizard. In a song that calls for sincerity — or at least, the performance of sincerity —his inherent Jeff Goldblum-ness becomes more glaring.
10.
“Dear Old Shiz”
What can I say? Aside from giving Galinda a chance to show off her high notes — and you can never have too many of those moments, whether it’s Ariana Grande, Kristen Chenoweth, or any of the other soprano divas who’ve played the Good Witch over the years — there’s not much here. Even the introduction of Keala Settle’s Miss Coddle can’t do much to make “Dear Old Shiz” stand out. (No fault of Settle’s; it’s just not a “This Is Me” moment.) At the same time, everyone sounds great. Whether through the magic of live singing or the magic of post-production, their voices meld together beautifully.
There’s really no other place to rank “Dear Old Shiz” than near the bottom of the list, though the biggest mark against it isn’t even the song so much as the way that Elphaba’s arrival pulls focus.
9.
“Something Bad”
Perhaps the most infamous skip on the Original Broadway Cast Recording, “Something Bad” is better than expected in the Wicked movie. This is Doctor Dillamond’s big moment, and as many quibbles as I have with the CGI throughout the film — more on this shortly — I’ll concede they did a pretty good job transforming Peter Dinklage into a goat. (He certainly looks better than Elphaba’s Bear nanny.) And Dinklage’s singing voice is pleasant if not exceptional. He’s at least up to the task of this particular number.
As for the scene itself, Wicked does a lot of showing rather than telling, for better and for worse. In this case, the shadow puppet depiction of the persecution of Animals in Oz is quite effective and distracts from some of the less impressive CGI creations in Doctor Dillamond’s salon. This is almost certainly the best “Something Bad” we were going to get.
8.
“I’m Not That Girl”
Despite containing another of my favorite “you’re not gonna get away with this, Stephen Schwartz” lines (“she who’s winsome, she wins him”), “I’m Not That Girl” is not that girl in the Wicked movie. It’s well sung, obviously, and Cynthia Erivo fares best in the scenes where Elphaba is lovelorn and teary-eyed. But there’s an odd flatness to the number, and here’s where I do blame the CGI fuzziness that makes the whole forest look artificial.
The song itself does a lot of the heavy lifting, so it’s hard to complain too much. You just wish that Chu found a way to really lean into the intimacy of the number instead of trying to create a visual moment that Erivo gets lost in.
7.
“No One Mourns the Wicked”
The pleasant surprise of Wicked, a movie whose endless delays only increased my doubts, is that it works more often than it doesn’t. With that in mind, we’ve reached the point of the list where these are numbers I am largely positive on! “No One Mourns the Wicked” is an encouraging opening for the film, emphasizing Chu’s ability to pull off big production numbers and the care put into creating impressive practical sets. Munchkinland looks great, borrowing just enough from the 1939 Wizard of Oz while still feeling like its own thing.
My one complaint — aside from the aforementioned CGI Bear nanny in the flashback to Elphaba’s birth, a waste of the great Sharon D. Clarke — is that Ariana Grande seems a little overwhelmed by all the noise around her. This is where the scope of the film, as opposed to the Broadway production, comes into play. Grande’s Glinda is, hands down, the best performance in the movie, but the opening song has so much going on around her that she doesn’t stand out as much as she should.
6.
“One Short Day”
As in “No One Mourns the Wicked,” the thrill of “One Short Day” is in seeing how successfully the film pulls off these locations. The Emerald City looks fantastic and contained — the latter might seem like damning with faint praise, but given how overwhelming Wicked can be, it’s nice that there’s some restraint here.
While the song itself has never been a personal fave, Erivo and Grande sound incredible together (this will become a recurring theme), and we get an expanded Wizomania featuring original Broadway stars Idina Menzel and Kristin Chenoweth. It’s good to see them, isn’t it? Yeah, we probably don’t need the added exposition, and the way they immediately fall into the Elphaba and Glinda roles is ultimately distracting, but the key to Wicked is not taking it too seriously, and this fits that approach well.
5.
“The Wizard and I”
If this were a ranking of the best songs in Wicked the musical, “The Wizard and I” would be nearly at the top. It’s still a banger in the movie, naturally, again performed well by Erivo. She even manages to do the “no father is not proud of you” line without making it sound awkward, a constant struggle for Elphabas who aren’t Lindsay Mendez. Even though Michelle Yeoh can’t really sing her brief part at the beginning of the song, you quickly forget about that when Elphaba is wandering through the practical Shiz sets.
It’s when she runs out to the cliffside that things get a little shakier, and the artificiality of the CGI backgrounds and confusing lighting takes over. There’s also the overly literal depiction of Elphaba having “a vision almost like a prophecy” — we actually don’t need that! We just saw “No One Mourns the Wicked,” and can probably put two and two together on our own. Erivo’s performance remains solid throughout, though she’s better at the longing than the musical comedy.
4.
“What Is This Feeling?”
The split screen in “What Is This Feeling?” is the first time I felt confident that Chu was going to pull this movie off. Here’s something that feels distinctly cinematic — you can’t do that onstage, and it immediately elevates this number to the top tier. It also emphasizes the Sapphic undertones, but if you didn’t already understand “What Is This Feeling?” to be a love song, (Sarah Paulson in Carol voice) I can’t help you with that.
It really can’t be overemphasized how good Erivo and Grande sound together, so forgive me for bringing it up again. As Elphaba and Galinda move through a number of scenes and Shiz sets — more credit to the stellar production design — the actors’ harmonizing keeps the number grounded. It’s a magic trick.
3.
“Popular”
It’s clear that Grande is Wicked’s most valuable player well before “Popular.” She creates a Galinda — still with the “Gah” at this point in the movie — who pays homage to the Galindas before her without feeling overly derivative. You can tell Grande grew up as a superfan of the show, but also understands the importance of leaving her own mark. It’s no surprise, then, that she nails “Popular,” delivering ample natural humor and vocal riffs that somehow don’t feel overly showy.
Again, Chu manages to insert a movie moment that couldn’t be done onstage in the makeover montage. See also: the camera shooting from above as Galinda does her best Esther Williams (without the pool) on the dorm room floor. There are so many little moments I could point to, like Grande doing Evita arms on “especially great communicators.” By the time the set is bathed in pink light and she options up for the third time, you realize you’re watching a future classic movie musical moment.
2.
“Defying Gravity”
“Defying Gravity” is undeniable. It’s a showstopper so showstopping that they decided to break Wicked into two movies. (Whether or not they actually needed to do this is something you can debate elsewhere.) Because it’s the most potent moment in the show, and because Erivo and Grande sound unbelievable — have I mentioned that they harmonize well? — it was never not going to be at the top of this list.
Well, near the top. There are a few reasons “Defying Gravity” misses out on the number-one slot. The biggest issue is how much action Wicked incorporates into the big finale, particularly at the end of the song. There’s an extended sequence where Elphaba falls instead of flying and sees her younger self before she’s able to grab her broomstick. That’s followed by a bunch of aerial tricks as she evades the flying monkeys. The entire “so if you care to find me” verse ends up delayed, and then the final lines and the iconic battle cry are delayed even further. It’s sort of like watching a music video with too many dialogue scenes in it. I want to hear the song!
But look. It’s “Defying Gravity.” You’re going to cry. You’re going to feel stirred. You’re going to gag at Elphaba’s silhouette in full Wicked Witch of the West garb. While I wish the film let the song unleash its full power — battle cry and smash cut to black is the obvious choice, not more Elphaba flying — it’s still a remarkable number that more than justifies adapting the musical to the big screen.
1.
“Dancing Through Life”
Maybe it’s because I’m not immune to Jonathan Bailey’s charms. Maybe it’s because I’m finding myself in a very “life’s more painless for the brainless” place of late. But “Dancing Through Life” is my pick for the standout musical number in Wicked, a lengthy sequence with an abundance of moving parts (and a moving library set) that comes together into something extraordinary. Bailey is certainly a big part of the song’s success: He sounds great, and his irresistible pansexual Fiyero takes the film to the next level.
Do I love the new arrangement of the song? I do not! And yet, Bailey makes it work, with help from some really impressive choreo and more eye-catching sets — the aforementioned library, and also the underwater Ozdust Ballroom, complete with an Animal band (Sugar Glider on drums!). It’s not just Fiyero singing, though. “Dancing Through Life” is also a nice spotlight for Marissa Bode and Ethan Slater. The latter powers his way through the ultimate “you’re not gonna get away with this, Stephen Schwartz” rhyme: “Nessa, I’ve got something to confess, a …”
Wicked is two hours and 40 minutes long, which is shocking when you consider that it’s only the first half of a musical that’s about the same length. “Dancing Through Life” is definitely drawn out, making a meal out of Elphaba’s entrance to the Ozdust Ballroom and her unusual dance once she gets there. But the choice to slow things down pays off when Galinda joins her in one of the movie’s more moving moments. From start to finish, the entire sequence is a welcome reminder of the musical’s power — and a perfect encapsulation of how well this cast and creative team have translated that to the film.
By submitting your email, you agree to our
Terms and Privacy Notice
and to receive email correspondence from us. This site is protected by reCAPTCHA and the Google
Privacy Policy and
Terms of Service apply.
or
Already a subscriber?
What is your email?
This email will be used to sign into all New York sites. By submitting your email, you agree to our Terms and Privacy Policy and to receive email correspondence from us.
Password must be at least 8 characters and contain:
Lower case letters (a-z)
Upper case letters (A-Z)
Numbers (0-9)
Special Characters (!@#$%^&*)
This password will be used to sign into all New York sites. By submitting your email, you agree to our Terms and Privacy Policy and to receive email correspondence from us.
You’re in!
As part of your account, you’ll receive occasional updates and offers from New York, which you can opt out of anytime.
or
Already a subscriber?
What is your email?
This email will be used to sign into all New York sites. By submitting your email, you agree to our Terms and Privacy Policy and to receive email correspondence from us.
Password must be at least 8 characters and contain:
Lower case letters (a-z)
Upper case letters (A-Z)
Numbers (0-9)
Special Characters (!@#$%^&*)
This password will be used to sign into all New York sites. By submitting your email, you agree to our Terms and Privacy Policy and to receive email correspondence from us.
You’re in!
As part of your account, you’ll receive occasional updates and offers from New York, which you can opt out of anytime.
Already a subscriber?
Already a subscriber?
`;
// integrate Sub(x) scripts and elements
if (hostname !== 'subs.nymag.com') { // do not integrate on this subdomain
document.head.appendChild(trackingScript);
document.body.insertAdjacentHTML('beforeend', subXAnimationElements);
}
There was an error processing the request. Please try again later."}).catch(e=>console.error("Error verifying email: ",e)))(r.querySelector(".content"),o.bannerCTAVerification)})):(l.remove(),s.remove()),o.dismissable||n.remove(),o.useAlertIcon||a.remove(),r.classList.add("show"),n.addEventListener("click",()=>{u(),r.classList.remove("show")})}else r.remove()}});
}, {"1":1,"6":6,"12":12,"35":35,"40":40}];
window.modules["global-nav.client"] = [function(require,module,exports){"use strict";const dom=require(3),auth=require(12),signInButton=dom.find(".user-signin"),signOutButton=dom.find(".user-signout"),globalNav=dom.find('[class^="global-nav"]'),body=dom.find("body"),dropdownItems=dom.findAll(".dropdown-wrap"),gtm=require(1),appendLandingPageParams=require(136),pageUri=require(124).getPageUri(),subscriptionPromoLinks=dom.findAll(".persist-params"),searchString=window.location.search||"";function closeDropdowns(e){let n=globalNav.querySelectorAll(".dropdown.open");dropdownItems.forEach(function(t){let o=t.querySelector(".dropdown");!n||t.contains(e.target)&&27!==e.keyCode||o.classList.remove("open")})}function gtmSendReport(e,n,t){let o={eventCategory:"ecommerce",eventAction:"componentClick",brand:e,dimension23:"global-nav",list:pageUri,pageZone:"header",variant:"nav-link"};"global-nav-link"===t&&(o.eventLabel=n.href),gtm.reportNow(o)}function updateElementTargetUrlsIfQueryStrings(e){if(searchString){const n=new URLSearchParams(searchString);let t=e.href;if(t.includes("?")){const o=t.split("?"),i=new URLSearchParams(o[1]);for(let e of n.entries())i.set(e[0],e[1]);t=`${o[0]}?${i.toString()}`,e.href=t}else e.href=`${t}?${n.toString()}`}}function init(e){const n=e.querySelectorAll(".to-landing-page");window.addEventListener("auth:init",()=>{signInButton.addEventListener("click",function(e){e.preventDefault(),auth.showEmbeddedLoginFlow("top navigation")}),signOutButton.addEventListener("click",function(e){e.preventDefault(),gtmSendReport("Sign Out",e.target,"user-info-link"),auth.logout()}),auth.isAuthenticated()&&e.classList.add("signed-in"),auth.isSubscriber()&&e.classList.add("subscribed"),e.querySelectorAll(".user-link").forEach(e=>{e.classList.add("active")}),subscriptionPromoLinks.forEach(e=>{updateElementTargetUrlsIfQueryStrings(e)}),appendLandingPageParams(n)})}dropdownItems.forEach(function(e){e.addEventListener("click",function(){e.querySelector(".dropdown").classList.toggle("open")})}),body.addEventListener("click",closeDropdowns),document.addEventListener("keydown",closeDropdowns),globalNav.addEventListener("click",function(e){let n=e.target;n.classList.contains("global-nav-track")&>mSendReport(n.text,n,"global-nav-link")}),module.exports=init;
}, {"1":1,"3":3,"12":12,"124":124,"136":136}];
window.modules["aaa-module-mounting.legacy"] = [function(require,module,exports){"use strict";const _pickBy=require(221),_each=require(408),Fingerprint2=require(407),DS=require(406),Eventify=require(246);function registerGlobals(){window.DS=DS,window.Eventify=Eventify,window.Fingerprint2=Fingerprint2,DS.value("Eventify",Eventify),DS.value("Fingerprint2",Fingerprint2),DS.value("$document",window.document),DS.value("$window",window)}function mountDollarSliceComponents(){DS.service("components",["$document","$module",function(e,n){var o=_pickBy(n.definitions,e=>e.providerStrategy===n.providers.controller),r=Object.keys(o);function t(e){return o=>{try{n.get(e,o)}catch(e){logMountError(o,e)}}}_each(r,n=>{var o=e.querySelectorAll('[data-uri*="/_components/'+n+'/"]'),r=e.querySelectorAll('[data-uri$="/_components/'+n+'"]');_each(o,t(n)),_each(r,t(n))}),this.components=r}]),DS.get("components")}function logMountError(e,n){const o=e.outerHTML.slice(0,e.outerHTML.indexOf(e.innerHTML));console.error("Error attaching controller to "+o,n)}registerGlobals(),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>{mountDollarSliceComponents()}):mountDollarSliceComponents();
}, {"221":221,"246":246,"406":406,"407":407,"408":408}];
window.modules["ads.legacy"] = [function(require,module,exports){"use strict";const _map=require(118),_forEach=require(107),_isString=require(268),_intersectionWith=require(409),_isEqual=require(274),_each=require(408),_debounce=require(182),_sortBy=require(205),page=require(124),visit=require(114);DS.service("adService",["Eventify","$cid","$document","$window",function(e,t,a,i){var o,n,s,r,d,c,u,l,g={},p=this,h=[],f=visit.getQueryParamsObject(["utm_campaign"]),m=document.querySelector('script[data-type="ad-a9"]'),b=[],w=!1,v=[],y=document.querySelector('script[data-name="ad-doubleverify"]');document.querySelector('script[data-name="concert-ads"]')||(i.NYM={},i.NYM.analytics={},i.NYM.analytics.adStartTime=i.performance.now(),i.googletag=i.googletag||{},i.googletag.cmd=i.googletag.cmd||[],u=i.googletag,(m||y)&&(i.googletag.cmd=i.googletag.cmd||[],i.googletag.cmd.push(function(){i.googletag.pubads().disableInitialLoad()})),m&&(l=i.setInterval(function(){void 0!==window.apstag&&void 0!==window.apstag.timeout&&(i.clearInterval(l),window.apstag.cleared=!0,l=null)},10),setTimeout(function(){l&&(i.clearInterval(l),i.googletag.pubads().refresh(),window.apstag||console.log("MESSAGE: Timeout for A9 load exceeded, aborting"))},500)),y&&(b.push(new Promise(function(e){w?e():v.push(e)})),c=i.setTimeout(T,2500)),o=function(e){var t,a,o=e.data,n=[];return o.loaded?e:(o.loaded=!0,t=null,(t=o.sizes?u.defineSlot(o.name,o.sizes,o.id).addService(u.pubads()):u.defineOutOfPageSlot(o.name,o.id).addService(u.pubads())).setTargeting("adid",o.id),f.hasOwnProperty("utm_campaign")&&t.setTargeting("utmcamp",f.utm_campaign),a=p.getAdCount(o.label),t.setTargeting("label",o.label+"_"+o.site+"-"+a),u.display(o.id),u.pubads().addEventListener("slotOnload",function(){i.NYM.analytics.firstAdLoadTime||(i.NYM.analytics.firstAdLoadTime=i.performance.now(),i.NYM.analytics.firstAdLoadLabel=e.data.label)}),n=_(o),Promise.all(b).then(function(){n?window.apstag&&window.apstag.cleared?window.apstag.fetchBids({slots:[n],timeout:window.apstag.timeout},function(){u.cmd.push(function(){window.apstag.setDisplayBids(),u.pubads().refresh([t],{changeCorrelator:!1})})}):y&&u.pubads().refresh([t],{changeCorrelator:!1}):u.pubads().refresh([t],{changeCorrelator:!1})}),e.slot=t,e)},n=function(e){var a,i,o,n=t(),s=e.getAttribute("data-name"),r=e.getAttribute("data-sizes"),d=e.getAttribute("data-label"),c=e.getAttribute("data-site");n=e.id,r&&r.length?(r=r.split(","),a=[],_map(r,function(e){e=e.split("x"),i=parseInt(e[0]),o=parseInt(e[1]),a.push([i,o])})):(e.classList.add("oop"),a=!1),this.data={id:n,name:s,sizes:a,loaded:!1,label:d,site:c},g[n]=this},r=function(e){u.cmd.push(function(){var t=o(e);g[e.data.id]=t})},s=function(e){var t=[];e.slot?(t=_(e))&&window.apstag&&window.apstag.cleared&&window.apstag.fetchBids({slots:[t],timeout:window.apstag.timeout},function(){u.cmd.push(function(){window.apstag.setDisplayBids(),u.pubads().refresh([e.slot],{changeCorrelator:!1})})}):e&&r(e)},u.cmd.push(function(){var e,t,o,n=page.getMeta("article:tag"),s=page.getMeta("author"),r=i.location.href,d=(e=a.head.querySelector(".head-gtm"),t=a.body.querySelector(".gtm"),e&&"top"===e.getAttribute("data-gtm")?"gtmtop":t&&"bottom"===t.getAttribute("data-gtm")?"gtmbottom":"");o=[],_forEach([n,s,d],function(e){_forEach(e.split(","),function(e){(e=e.trim().toLowerCase().replace(/\s/g,"-").replace(/\'|\’/g,"")).length&&o.push(e)})}),u.pubads().setTargeting("kw",o),u.pubads().setTargeting("entry_group",o),r=r.slice(r.lastIndexOf("/")+1),u.pubads().setTargeting("pn",r),u.companionAds().setRefreshUnfilledSlots(!0),u.pubads().enableAsyncRendering(),u.enableServices()}),this.load=r,this.create=function(e){return new n(e)},this.refresh=function(e){var t;_isString(e)?(t=this.getById(e),s(t)):s(e)},this.remove=function(e){var t=e.data.id;a.getElementById(t).innerHTML=""},this.getAdCount=function(e){var t,a=0,i=Object.keys(g);return _each(i,function(i){(t=g[i]).data.loaded&&t.data.label===e&&a++}),a},this.getById=function(e){return g[e]},d=_debounce(function(){var e={TopLeaderboard:1,RightColTopMPU:2,outOfPage:99,"homepageTakeover/TopLeaderboard":1},t=_sortBy(h,function(t){return e[t.data.label]||10});_forEach(t,function(e){return e.data.sizes?r(e):i.setTimeout(function(){r(e)},2e3)}),y&&window.PQ.cmd.push(()=>{try{window.PQ.loadSignals(["ids","bsc","vlp"],T)}catch(e){T(),console.error(`There has been an error loading Double Verify signals: ${e}`)}}),h=[]},10),this.addToPageLoadQueue=function(e){h.push(e),d()});function _(e){var t,a=e.sizes;return a=_intersectionWith(a,[[970,250],[970,90],[728,90],[300,600],[300,250],[320,100],[320,50]],_isEqual),e.sizes&&e.sizes.length&&(t={slotID:e.id,sizes:a,slotName:e.label}),t}function T(){i.clearTimeout(c),w=!0,_forEach(v,function(e){e()})}}]);
}, {"107":107,"114":114,"118":118,"124":124,"182":182,"205":205,"268":268,"274":274,"408":408,"409":409}];
window.modules["cid.legacy"] = [function(require,module,exports){"use strict";DS.service("$cid",function(){var r=Math.floor(100*Math.random());return function(){return"cid-"+ ++r}});
}, {}];
window.modules["client.legacy"] = [function(require,module,exports){"use strict";require("cid.legacy"),require("ads.legacy"),require("facebook.legacy"),require("aaa-module-mounting.legacy");
}, {"cid.legacy":"cid.legacy","aaa-module-mounting.legacy":"aaa-module-mounting.legacy","ads.legacy":"ads.legacy","facebook.legacy":"facebook.legacy"}];
window.modules["facebook.legacy"] = [function(require,module,exports){"use strict";DS.service("facebook",[function(){this.fb=function(i){window.FB&&window.FB[i].apply(this,Array.prototype.slice.call(arguments,1))}}]);
}, {}];
require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o typeof key === 'string' && key.match(/\.legacy$/)).forEach(key => window.require(key));
}
function tryToMount(fn, el, name) {
try {
fn(el); // init the controller
} catch (e) {
const elementTag = el.outerHTML.slice(0, el.outerHTML.indexOf(el.innerHTML));
console.error(`Error initializing controller for "${name}" on "${elementTag}"`, e);
}
}
/**
* mount client.js component controllers
*/
function mountComponentModules() {
Object.keys(window.modules).filter(key => typeof key === 'string' && key.match(/\.client$/)).forEach(key => {
let controllerFn = window.require(key);
if (typeof controllerFn === 'function') {
const name = key.replace('.client', ''),
instancesSelector = `[data-uri*="_components/${name}/"]`,
defaultSelector = `[data-uri$="_components${name}"]`,
instances = document.querySelectorAll(instancesSelector),
defaults = document.querySelectorAll(defaultSelector);
for (let el of instances) {
tryToMount(controllerFn, el, name);
}
for (let el of defaults) {
tryToMount(controllerFn, el, name);
}
}
});
}
// Make sure that a `window.process.env.NODE_ENV` is available in the client for any dependencies,
// services, or components that could require it
// note: the `` value is swapped for the actual environment variable in /lib/cmd/compile/scripts.js
window.process = window.process || {};
window.process.env = window.process.env || {};
if (!window.process.env.NODE_ENV) {
window.process.env.NODE_ENV = '';
}
// note: legacy controllers that require legacy services (e.g. dollar-slice) must
// wait for DOMContentLoaded to initialize themselves, as the files themselves must be mounted first
mountLegacyServices();
mountComponentModules();
// ]]