What I saw, overheard, and swallowed behind the scenes at the 2024 Oscars.
ByRachel Handler,
a features writer at Vulture and New York
Yvonne McGuinness (right of Cillian Murphy), my new friend.
Photo: Patrick T. Fallon/AFP via Getty Images
Yvonne McGuinness (right of Cillian Murphy), my new friend.
Photo: Patrick T. Fallon/AFP via Getty Images
I experience my first Academy Awards weekend in 4K, as a delightfully immersive and occasionally destabilizing multisensory experience. It starts on Friday, when I attend a pre-Oscars party at a mansion on a hilltop, hosted by Vanity Fair and Yves Saint Laurent to celebrate Oppenheimer, a film about that time the United States dropped two nuclear bombs on Japan. Every single person is wearing black and smoking, perhaps as some kind of light homage. They often ask each other if they are wearing YSL and mostly the answer is yes; nobody eats the cheeseburgers being passed around. I see Christopher Nolan and Cillian Murphy chatting with people, but then I see Josh Hartnett and decide I need to pay off a long-standing psychic debt to my 12-year-old self and speak to him first. He’s chatting with Alex Wolff, who pulls a small box out of his suit jacket to reveal two tiny mints, explaining that they are “from Japan” and “not drugs.” I eat one — I trust him, he was in Hereditary and knows why Ari Aster is like that about moms— and turn to Josh to say something about Pearl Harbor, realizing that he has actively participated in fictional World War II from multiple (2) angles. I also bring up The Faculty and he says, “Yeah, wow, that was in like, 1998.”
The interior of the hilltop mansion looks like a preserved Mad Men set, complete with actual Jon Hamm walking around with a wife, except Hailey Bieber is also there, which sort of cancels out the period-perfect effect. I head for a bathroom attached to one of the bedrooms, which is empty save for Sharon Stone sitting casually on a bed with a friend, wearing glasses, looking absolutely amazing. She compliments my shoes, which are dirty, and we discuss how hard it is to wear heels for more than a few minutes. Keegan Michael Key walks in and remarks on the floors (they are good) and leaves. Other party attendees include Zoe Kravitz and Channing Tatum and dozens of women I vaguely recognize from Instagram, who wander around flammably near heat lamps and fire pits. Dominic Sessa of The Holdovers talks to Billie Eilish’s brother. I see Lottie from Yellowjackets and feel relieved to see a friend but then have to keep reminding myself I don’t actually know her. Back in Sharon Stone’s adopted bedroom, I volunteer to take photos for a woman I soon learn is Cillian Murphy’s wife and her friends, who are having more fun than anyone else here.
On Saturday I run around to various expensive hotels across Los Angeles to pick up the tickets necessary for me to attend the Academy Awards, including a wristband that allows me to leave my floor at the Oscars to visit other, more famous floors. When I’m done, I meet a luxury artisan at my hotel pool and we end up in her hotel room perusing her wares, which run upwards of $200,000, and then I somehow end up buying her oat milk at Erehwon. Soon thereafter I am standing completely naked with my arms bent downward like a broken marionette getting a last minute $250 spray tan in Beverly Hills. The Oscars will do things like this to you and you must accept it, there is no point in resistance.
A picture of Jimmy Kimmel, Oscarshost, that captures the approximate distance between my seat and the stage.
Photo: Patrick T. Fallon/AFP via Getty Images
On the day of the awards, Hazel and Wendy, the housekeeping staff at the Short Stories Hotel, agree to zip me into my dress. I carry my bricklike mobile charger necessary to power my crucial observations in my hand because it doesn’t fit in my purse. To physically get into Hollywood’s Dolby Theater, where the Oscars are held every year, is a Zelda-esque vision quest; my Uber driver and I fail over and over at deciphering the riddle-like directions for cars approaching the event and I end up staggering many city blocks by foot in already painful heels. Several people on the way pump me for ceremony tickets and many L.A. private and public security officers compliment my outfit as I hobble. I arrive at 2:30 p.m., the same time as Dwyane Wade and Gabrielle Union, but am unable to pause and look at them due to a giant hedge eventually separating my red carpet (for normies) from their red carpet (the real one).
Once inside the Dolby, I wander down endless red carpeted halls like I am Danny in The Shining. Everyone is trying to take the same selfie with a giant Oscar statue and the same group selfie at the bottom of some red stairs. I hide behind a large column at the top of those stairs and clock the celebs who are an hour-plus early to the event: Nicolas Cage, Matt Bomer, Zone of Interest director Jonathan Glazer, who sneaks by most people unnoticed, as does my good friend Josh Hartnett (in sunglasses) and his wife Tamsin Egerton; we don’t speak because we have said all we needed to say. Another reporter tells me that I don’t actually need to be in my assigned seat inside the theater by 3:30 (even though the Academy told me that I did) and also that everyone is now getting micro facelifts. Diana Nyad and Bonnie Stoll stop to chat with a group of fans. Diana is raving about Bradley Cooper and stressing about the camera angle that might hit her if she’s sitting in the balcony. Ke Huy Quan and Colman Domingo hold each other’s hands intensely and tell each other they look stunning.
Once I am finally in my balcony seat one minute before the ceremony begins, the actor and comedian David Alan Grier warms up the crowd and calls himself a “zaddy.” “Don’t fuck this up,” he warns the nominees, vaguely. Ariana Grande floofs into the audience below me in Barbie pink; her dress fills her entire seat and its surrounding area like a gay emergency parachute. She is one of the only famous people I can see from my perch. I will report on her reactions to stuff when possible — for example, she really liked ceremony host Jimmy Kimmel’s monologue joke about the heavy themes in German movies, and she nodded heavily at his remark about members of the Screen Actors Guild not wanting to be replaced by AI. She, Cynthia Erivo, and Lena Waithe chat excitedly at commercial breaks in between looking intently at their phones.
Back in the hallway, at a bar that will prove very popular as the night drags on, is Annette Bening. “Can we take the drinks in?” she asks the bartender, gesturing to the theater. She can. “I don’t know if I can do gin and tonic on an empty stomach,” she adds, and orders a white wine. Florence Pugh asks for two olives in a cup and eats one, then hands the cup back. “I can’t finish that one,” she says apologetically, and orders a Chardonnay before running back to chat intently with Kirsten Dunst and Jesse Plemons. I nervously rub my tourist wristband, which allows me access to this bar to mill among the celebrities but with a gigantic visual reminder that I am not one of them.
Commercial breaks induce madness. By the second one, Emma Stone and Mark Ruffalo race out of the theater to pee and Emma gets caught up in a convo with Kirsten Dunst, who’s still haunting the area in a very chic way. In the process, Emma misses a Poor Thingswin for production design: “Oh my god!” She watches the speech, visibly emotional, on the monitors near the bar. Florence, now drinking a vodka soda, hugs her. They poke at each other’s dresses. “We’re missing Cena naked,” observes Florence when she returns to the monitors. “What is happening?” asks a nearby Eva Longoria. “John Cena is naked,” reiterates Emma. Poor Things continues to win and Emma screams. Florence rubs her back, “Oh, babe,” she says as her friend tears up. “Where’s Mark? Where the fuck is Mark?” asks Emma.
Kens.
Photo: Patrick T. Fallon/AFP via Getty Images
Greta Gerwig suddenly appears and orders a drink while her husband Noah Baumbach goes to the bathroom with a child (his own?); they reconvene at the bar as a family. “I feel like I fucked it up,” says Greta, about something mysterious. “I just feel like I’m not doing the Oscars well,” she jokingly announces to the people surrounding her. I see a woman carrying what appears to be Ariana Grande’s dress like a corpse into the elevators. Ava DuVernay walks by in a pin calling for ceasefire, one of the only people I see wearing one. Florence reappears. She realizes she is missing I’m Just Ken; this girl can’t catch a break. I end up watching Ryan Gosling’s Best Song performance standing next to her by the monitors. “Are you Best Dressed?” someone on her team asks her, showing her a cell phone where someone has ostensibly named her as such. She giggles and everyone says congratulations.
The bar cheers raucously as the cowboy Kens flood the lobby after the song. A “Ken!” chant spontaneously begins. Emma returns to the bar again and this time gets ensnared in a convo with Grace Gummer; a publicist reminds Emma to re-enter the ceremony lest she miss her movie’s category again. A trickle of blood leaves my shoe as I notice Danielle Brooks has changed into sparkly sneakers. The room is increasingly filling with people “from TikTok.” On the monitors, I watch my personal friend (Cillian Murphy’s wife) kiss him sensually as he wins Best Actor and feel thrilled for her. “I thought Oppenheimer was mediocre,” says a man behind me. It goes on to win Best Picture.
The celebrities pour out after the Best Picture acceptance speech — The Rock first, JLaw tanly clutching her art husband’s hand. Several people hug the hot lawyer from Anatomy of a Fall. Ryan Gosling and Greta Gerwig stand and receive admirers at the end of the ramp to the theater’s bar and lobby. Lily Gladstone stands away from the hullabaloo near the door of the theater, in bright yellow star sunglasses, looking a little bummed after her Best Actress loss but gorgeous. Greta Gerwig yells at her parents on the phone to meet her at the elevators, where they all ascend to the Governor’s Ball. The lobby empties, but Messi the dog wanders in. It’s his time now.
His.
Photo: Kevin Winter/Getty Images
Over the course of the weekend, multiple people ask me what outfit I will be “changing into for the Vanity Fair party,” as it is celebrity custom to swap clothes after the Oscars ceremony. My personal stylist (me) only provided me with one outfit and my driver (UberX) does not have the bandwidth to take me back to my hotel. “Maybe you’ll see Will Smith,” says my Uber driver as he drops me off at the Annenberg Center. “Oh wait. He’s banned.”
Sandra Hüller is at the entrance to the party, trying to exit. “We have to go through to exit,” her assistant says several times, which becomes a kind of Zen koan for me. Suddenly we are trapped in another Kubrickian hallway with Greta Lee, and she and Sandra take photos together. Once inside the party, held in a massive room with a DJ booth and an outdoor deck where people are making bespoke pizzas, someone hands me a shot glass made out of chocolate and filled with tequila. Steven Spielberg smiles at Haim, who are dancing to Usher, as are the Bailey sisters nearby, who don’t let go of each other’s hands. Demi Moore and a considerable portion of her daughters stand near Ted Danson, who is hugging Elizabeth Banks. Lindsay Lohan side-hugs Flava Flav (he’s a big fan, he tells me). Transparent siblings Gaby Hoffmann and Josh Duplass are continuously requesting songs from the DJ — Gaby tells me she’s asked several times for Whitney Houston. Jodie Foster, her wife Alexandra Hedison, and Brandi Carlile form a small chatty circle near Renee Rapp and Towa Bird, creating what is briefly my dream lesbian cabal. Jodie Turner-Smith joyfully screams, “Florence, you cunt!” at Florence Pugh near the bathrooms and they hug passionately.
I’ve never been at a party with more famous people grouped into more random pairings, each more surreal than the last. Nicole Richie and Maggie Rogers. Kathryn Hahn and Jason Ritter. Cynthia Erivo and Tan France. Camila Cabello and Nicholas Galitzine. Lupita Nyong’o and Joe Keery. Hannah Einbinder and Julia Fox. Ice Spice and Sheryl Lee Ralph. Jeffrey Wright and John Waters. Cardi B and Jodie Foster. Josh Hartnett, my leitmotif, and an In-N-Out Burger.
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();
// ]]