Boo!
Photo: Lionsgate, Warner Brothers, Universal Studios, Sundance Institute
This story was originally published in 2016 and has been updated to include additional home-invasion movies.
Home-invasion movies are driven by a universal fear: Who hasn’t worried about someone breaking into their home with malicious intent? It’s why creaks and bumps scare you when you’re home alone. It’s why wind chimes become instruments of terror when the sun goes down. It’s pretty twisted to think about watching movies that exploit these fears for fun, but there’s something to be said for sharing such an emotional experience with people from across the world. The universal fear of domestic violation transcends language and local custom. It’s the connective power of art in practice, manifested in mutual terror.
Below, we present 28 home-invasion movies to ensure that you don’t sleep soundly until Christmas. There’s plenty here for both the bloodhounds and those who prefer less gory frights.
The Desperate Hours (1955)
There are two movies called TheDesperate Hours. The one you should watch is from 1955 and stars Humphrey Bogart. The other is from 1990, and it’s not very good at all. The Bogart one was directed by William Wyler and is about three escaped felons who break into a random suburban home and take a family hostage for days on end. It’s home invasion for the gentler sensibility of the mid-1950s.
Audrey Hepburn got an Oscar nomination for her performance in this film as Suzy, a newly blind woman home alone in her apartment in New York City while three criminals try to manipulate her out of a possession she doesn’t even know she has. Watching three men gaslight a vulnerable woman evokes a timeless anxiety and fear, and Hepburn earned every bit of praise she got for this role.
Sure, this one is a zombie classic, but the zombies very much are invading a home, so this counts. Night of the Living Dead is also in the public domain, which means it is available to watch pretty much anywhere, on any streaming service.
In an effort to build a more soothing and simple life, David and his wife, Amy, move from the United States to the rural English town where she was raised. The men of the village don’t take kindly to David, not least of all because one of them used to date his wife. After two local men rape Amy, a violent siege of the couple’s home ensues. This is Dustin Hoffman’s beast mode.
Torso (1973)
Add some texture to your home-invasion experience with this Italian giallo film. After a serial killer begins targeting students in Perugia, a group of women decide to head for the hills and spend some time at a country villa. The killer follows them, and it doesn’t end well for most of the coeds. In the tradition of giallo, expect the blood to run bright red and the clothes to be sparse.
Here is a universal truth: The scariest killer is the killer who’s already in the house. The added bonus of Black Christmas is that it’s still a home invasion whether you consider it from the perspective of the villain or the victims, who in this case are a bunch of sorority girls hoping to enjoy their imminent winter break.
The first 30 minutes of When a Stranger Calls capitalize on the fundamental terror of home invasion in a way that few movies have ever been able to replicate. Is any question more chilling than “Have you checked the children?” It’s the line that puts this movie in the horror hall of fame. Just remember: You want the original version of this movie, not the 2006 remake starring Camilla Belle.
This German film about a man who gets out of jail and immediately sets out to torture and kill is so stripped down and frantic that it feels real. The camerawork and sound design make you feel like you’re slipping into madness with the killer, and the scarcity of dialogue proves horror is a genre that, when executed correctly, is not dependent on language to provoke extreme discomfort.
Austrian director Michael Haneke’s divisive take on home-invasion horror is twisted, frightening, and at times maddening. Haneke toys with genre tropes, forcing the audience to feel very uncomfortable about their choice of entertainment. In this story about a lovely little family held hostage by a pair of well-dressed, well-mannered young men, no one comes away clean — especially not the people watching.
This is one of those ultraviolent movies that casual horror fans liked to name-drop in the mid-aughts to demonstrate that they’d seen some stuff. In addition to being really aggressive, the first half of High Tension is actually a wonderfully effective home-invasion movie about a college student who brings her best friend to her family’s farmhouse for the weekend. If the name of the director, Alexandre Aja, sounds familiar, it’s because he’s the same guy who made you question your humanity after you watched the 2006 remake of The Hills Have Eyes.
Before The Conjuring tested nerves with those scary hands clapping in the dark, the villains of Them chipped away at audiences’ sanity with some wretched noisemakers. Once again, it’s sweet and simple. A couple is alone in their dark, cavernous house, where they’re hunted by a mysterious person — or persons — who revel in torture. Exercise caution on this one. It’s a French film, and the French are straight crazy with their horror.
Haneke also directed the American remake of his film ten years later, and it’s essentially a shot-for-shot re-creation of the German-language original. Stateside audiences got Tim Roth and Naomi Watts as the loving husband and wife, and Haneke had a casting coup with his new villains: Michael Pitt and Brady Corbet excel as the creepy duo, who are vanilla on the outside with molten-hot sadistic centers. Good luck watching them in any other roles after you watch this movie.
This film follows a devastated pregnant widow who spends Christmas Eve waiting for her delivery appointment the next day. Outside her home, a mysterious, terrifying woman waits to break in and cut the baby out. We won’t spoil whether or not she succeeds, but be warned: This is a savage, bloody nightmare. They don’t call it New French Extremity for nothing.
The impact of this film vastly overshadows its poor critical performance. Upon its release, The Strangers became a home-invasion classic, which is a true testament to the power of this horror subgenre. The premise is simple: Liv Tyler and Scott Speedman are trapped in their house as three masked sociopaths taunt and terrorize them. No frills. No special effects. Just the fear of your ultimate safe space being violated and used against you.
This one came out at the tail end of the so-called Torture Porn era, and so it’s distinguished by elaborately constructed acts of violence that result in lots and lots of bloodshed. The Collector follows a burglar who thinks he’s scored big at a fancy house, but upon entering, the thief realizes it’s been wired for terror by a psychotic masked killer keeping the family hostage inside. With deadly traps everywhere, the house becomes the enemy.
There’s an American remake of this Uruguayan film starring Elizabeth Olsen that is good enough to merit inclusion on this list (we will get to it shortly), but La Casa Muda is the stronger of the two. Each is distinct enough from the other — including in their respective executions of the crucial final scene — that they feel like unique experiences. If you’ve ever been afraid of the dark, this movie will be enough to make you consider sleeping with every pillow and blanket pulled over your head.
Kidnapped (2010)
A trio of masked criminals infiltrate a home in a gated Madrid community and take an entire family hostage in this Spanish thriller. If you run the credited names of the villains through a translation filter, they come out to Young Mugger, Chief Mugger, and Head Strong, which makes their characters sound a lot sillier than they actually are. These are definitely bad men.
Elizabeth Olsen actually made this movie before her breakout performance in Martha Marcy May Marlene, but it wasn’t released until after that film raised her profile. It’s an American remake of La Casa Muda, and it follows a young woman and her father staying overnight in a derelict vacation home they’re in the process of cleaning up. The movie received fairly poor reviews, but Olsen’s slide into fear and paranoia is truly gripping. Watch this one with the lights off and you’ll be right there in hell with her.
Perhaps the world experienced a collective subconscious fear in 2010, because home-invasion horror inspired a lot of filmmakers at that time. You’re Next has the advantage of showcasing an outstanding Final Girl, in addition to the standard tropes of the quiet family vacation home overrun by murderous crazies. And props to the filmmakers Adam Wingard and Simon Barrett for putting their baddies in very scary animal masks.
Before Anarchy and Election Night, there was the original Purge, a tight little home-invasion movie about a family trying to survive a night in which all crime is legal for 12 relentless, horrifying hours. As Lena Headey’s character reminds herself, “Just remember all the good the Purge does.”
How’s this for a movie description? “César is the superintendent of an apartment building and keeps very close tabs on the tenants. He secretly enjoys inflicting pain on others.” Pretty big secret, César! Sleep Tight will make you double-check that everything in your room is just where you left it — including under your bed, where you definitely did not leave a grown man.
This movie will appeal most to two sets of people: Those who love director Eli Roth and everything he does, and those interested in the strange but very satisfying Keanu Reeves comeback. The actor plays a married man home alone for the weekend who takes in a pair of very attractive women who claim they were caught in a rainstorm. He tries to get them to leave — but not that hard — and after making a few really bad choices he ends up as their prisoner in his own home. If you like the gleeful sociopaths of Roth’s previous films, this is a fun twist on his familiar tropes.
Don’t Breathe has the distinction of being a home-invasion movie where the invaders realize they are completely screwed when the blind man they show up to rob turns out to be a highly efficient killer. This film is also the follow-up for director Fede Álvarez after he broke out with the maybe best horror remake of all time, Evil Dead. (Keep quiet, The Thing stans!) Don’t Breathe could be accurately classified as stress horror, and since all horror is stressful, that should really tell you how tightly wound this movie is to get a special stress shout-out.
Here’s a terrifying question: What do you do if the sinister home invader is a woman pretending to be a babysitter and you entrust her with the lives of your children? That is the premise of Emelie, which is powered by an utterly disturbing performance from lead actress Sarah Bolger.
Actress Kate Siegel wrote this movie with director Mike Flanagan about a deaf woman living in the woods who ends up fighting for survival against a masked killer. Watching someone navigate the most desperate moments of her life while trapped in complete silence provokes a distinct type of anxiety, and Siegel does an excellent job.
Us (2019)
While Us eventually expands far beyond — and below — the normal confines of a home-invasion movie, the Tether families infiltrating the houses of their topside counterparts make for some of the best moments in the movie, especially when the Wilson family encounters them for the first time. Lupita Nyong’o and Winston Duke looking out in horror at their red-jumpsuited doppelgängers as they’re about to break inside is one of the most frightening sequences in 21st-century horror, and to this day we all know that Nyong’o was robbed of an Oscar nomination for her dual performances. Injustice!
Filmmaker Leigh Whannell got his footing in American horror with the Saw franchise, and after years of teaming up with James Wan to deliver scares at the script level, he has become one of the most reliable and exciting genre directors. His Invisible Man remake is a hair-raising, gaslighting, home-invading nightmare. An abusive, rich genius fakes his death after his wife finally flees from his clutches, only to continue resurfacing in her life … or is he? Elisabeth Moss’s Cecilia is terrorized by the thought of Adrian, her ex, hiding in every corner. She can feel him around her all of the time, but she’s driven to madness by the fact that neither she nor anyone else can see him! Whannell turns the camera into a villain of its own, panning across empty stretches and making you wonder if invisible Adrian is hidden somewhere in the frame, and it’s a trick that works every time! Also, nothing will prepare you for that one kill …
No One Will Save You is home invasion by way of aliens. The ever-effective Kaitlyn Dever plays Brynn, a woman living alone in her childhood home who suffers the dual shock of both her house being broken into and finding out the invaders aren’t from this world. No One was written and directed by Brian Duffield, who also penned the highly underrated Kristen Stewart thriller Underwater. This guy knows how to shove 20 pounds of tension into a ten-pound bag, and this alien-invaders movie proves he knows how to lace together a rip-roaring creature feature as both a scribe and a director.
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()}});
}, {"3":3,"6":6,"17":17,"35":35,"40":40}];
window.modules["global-nav.client"] = [function(require,module,exports){"use strict";const dom=require(4),auth=require(17),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(3),appendLandingPageParams=require(135),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 i=t.querySelector(".dropdown");!n||t.contains(e.target)&&27!==e.keyCode||i.classList.remove("open")})}function gtmSendReport(e,n,t){let i={eventCategory:"ecommerce",eventAction:"componentClick",brand:e,dimension23:"global-nav",list:pageUri,pageZone:"header",variant:"nav-link"};"global-nav-link"===t&&(i.eventLabel=n.href),gtm.reportNow(i)}function updateElementTargetUrlsIfQueryStrings(e){if(searchString){const n=new URLSearchParams(searchString);let t=e.href;if(t.includes("?")){const i=t.split("?"),o=new URLSearchParams(i[1]);for(let e of n.entries())o.set(e[0],e[1]);t=`${i[0]}?${o.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()||auth.isMobileAppRequest())&&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;
}, {"3":3,"4":4,"17":17,"124":124,"135":135}];
window.modules["aaa-module-mounting.legacy"] = [function(require,module,exports){"use strict";const _pickBy=require(221),_each=require(406),Fingerprint2=require(408),DS=require(407),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(406),_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,"406":406,"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","ads.legacy":"ads.legacy","facebook.legacy":"facebook.legacy","aaa-module-mounting.legacy":"aaa-module-mounting.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();
// ]]