When Network TV Gives Up: Franchises, Reboots, and Very Few Laughs
ByJosef Adalian,
who has covered the television industry since 1992and writes Buffering, a newsletter about streaming
CSI: Vegas, a “new” show coming to CBS.
Photo: Vulture; Photos by YouTube
Monday’s jaw-dropping announcement WarnerMedia was merging with Discovery Networks has overshadowed what would have otherwise been this week’s big entertainment industry story line — the virtual upfront presentations. Even before COVID, these events had been undergoing a major transformation: Instead of focusing on what the big broadcast networks have planned for fall, they’re now showcases for the supposed joys of conglomeration, cross-platform brand integration, and whatever made-up buzzwords the technocrats in charge of content have dreamed up this year. “IP is the new prime time,” one exec at WarnerMedia told the virtual crowd Wednesday morning. I truly have no idea what that even means.
Even though the coronavirus and corporate consolidation have drained most of the joy out of upfronts, this week is still important on the broadcast TV calendar. The Big Four broadcast networks have now all announced which new shows they’ll roll out next season and how they’ll be scheduled, something which matters far less than it once did but is not yet wholly irrelevant. On any given night, 12 to 15 million people still turn out to watch network shows in real (or almost-real) time. Millions more stream broadcast shows via Hulu or on network apps; millions more catch up eventually when reruns land on Netflix, Prime Video, or HBO Max. Streaming is now the center of the TV universe, but there’s still life out there in the network quadrants.
So what did we learn from this week’s announcements? Well, sadly, I can’t say there’s any reason to suspect we are in for a season of creative inspiration and bold attempts to reinvent the network paradigm. To the contrary, there seems to have been a collective decision that what network viewers want is more of the same — literally. There will be more versions of Law & Order, NCIS, America’s Got Talent, and FBI. There will be new iterations of CSI, The Wonder Years, Wheel of Fortune, Gordon Ramsay cooking competitions, and singing shows where people hide their true identities. There will be a whole lot less of networks even pretending to veer outside their established lanes. And there will be almost no experimentation with formats missing from prime-time TV but flourishing in streaming, like unscripted docuseries and specials. Instead, we’ll get another year of networks in survival mode, giving the audiences they still have more of what they think they want.
Short-term, this is probably a smart strategy, since it limits viewer erosion. But it will do nothing to grow the network audience, and yeah, I actually don’t think growth should be ruled out. Streaming is the future, but networks all have streaming platforms, too. Nielsen even measures some of those platforms. There’s a big audience for what we think of as “network” shows — easy-to-watch comfort food that doesn’t need to be gobbled over a weekend; series with relatable characters instead of troubled antiheroes; comedies which are actually funny. But instead of trying to find the next generation of such programming — the next This is Us, the new Modern Family — broadcasters seem to have decided they can’t risk taking the chances necessary to find those new hits. I hope they get their courage back.
Breaking Down Each Network’s Strategy
ABC’s The Wonder Years reboot.
Photo: Vulture; Photos by YouTube
As dismal and depressing as network TV’s overall trajectory is right now, broadcast execs are, for the most part, still gamely doing the best they can with the increasingly limited resources they’ve been allotted by their corporate overlords. When you don’t have $100 million to spend on a six-episode limited series starring two Oscar winners, you make due by setting more shows in Las Vegas and Hawaii, or betting folks want to watch sorta-famous folks spin a wheel and solve word puzzles. Here’s my quick verdict on the battle plans outlined by each of the Big Four networks, along with my personal picks for which of their shows looks most intriguing. (P.S. The CW skipped upfront week this year, choosing instead to unveil its new lineup next week.)
➽ Franchise fever at CBS, with one big lineup change. The Eye is notorious for its stability, whether in its scheduling (60 Minutes has been Sundays at seven since the dawn or time) or in content (Cop shows! Get your cop shows!). The network’s fall lineup absolutely sticks to tradition in terms of programming, with the very few shows not directly about cops/detectives either canceled (All Rise, MacGyver) or sent over to sister streamer Paramount+ (Seal Team, Evil, maybeClarice). They’re being replaced by new editions of FBI and NCIS, as well as a rebooted CSI.
But CBS isn’t playing it safe with its prime-time schedule. Since 1997, the network has kicked off Tuesday nights with a Navy-set crime-investigation series, starting with JAG and then continuing 18 years ago with the launch of spin-off NCIS. But this September, Tuesdays at 8 p.m. will be taken over by Dick Wolf’s FBI, with NCIS shifting to 9 p.m. Mondays. I get the logic of the move: It shores up a troubled Monday night lineup and gives CBS the ability to program three FBI shows in a row, à la NBC’s Wednesday Dicktacular lineup of Chicago shows. And networks shouldn’t make scheduling decisions based on sentiment. That said, a lot of folks in middle America will not appreciate having to stay up late for NCIS or a change in literally decades of tradition.
➽ Laugh-free NBC. There will be no comedies this fall on the network which was once home to Must-See TV, news that had some folks on Twitter kvetching about the end of an era. My response: Eh. Look, NBC long ago lost the ability to make good comedies that also appeal to the audiences who still watch network TV via actual television. Superstore, Parks and Rec, Young Rock, Mr. Mayor, and the salvaged final seasons of Brooklyn Nine-Nine are all great, and I think the larger NBCUniversal should absolutely be in the business of making such shows … for streaming. But unless and until NBC decides to make half-hours a lot of people like to watch — you know, like they watch its successful dramas — dumping shows into the crowded fall environment doesn’t make much sense.
Unfortunately, NBC’s plan to hold comedies ’til midseason because they’ll somehow magically be better able to find an audience isn’t that logical, either. Sure, the winter months are a tad less crowded, but the fundamental problem (NBC’s comedies are very niche) remains. I think a better idea would be to simply move all of the Peacock network’s comedies to the Peacock streaming platform and hope they find an audience there — or at least generate enough buzz to help the service add new subscribers. Peacock already has a great track record in comedy with Saved by the Bell (really!), Rutherford Falls, and my personal fave Girls 5Eva. Make it the new home for Must-See comedy, while NBC does what it should’ve done years ago: Let Dick Wolf make sitcoms.
Most promising new trailer: None, since NBC hasn’t released any yet. Ordinary Joeseems intriguing, though.)
➽ ABC phones it in. The Alphabet network used its upfront to make a big deal out of the fact that, if you take out sports programming, it’s actually the No. 1 network in adults 18 to 49. All is fair in TV spin, but advertisers certainly care a ton about sports content, and also, if you take The Bachelor out of the mix, I’m not so sure ABC would still be able to claim its invented crown. This is not to suggest ABC is in terrible shape headed into next season, at least not any more so than any broadcast network right now. The aforementioned Bachelor franchise is still plenty strong, Grey’s Anatomy remains a pop culture force,and newbies Big Sky and A Million Little Things have found respectable (if hardly blockbuster) audiences.
But ABC’s lineup is not doing so spectacularly well that it justifies launching just two new shows in the fall and making hardly any schedule changes. Slotting hip-hop drama Queens behind The Bachelorette on Tuesdays is smart on paper, as is the idea of putting Brandy and Eve together in a TV show. Everything else about ABC’s sked, however, suggests a network just going through the motions. Its Wednesday comedy block is tired and struggling, and the network’s response is to throw the promising reboot of The Wonder Years into the middle of the night and hope the name attracts viewers. And canceling a show from the exec producer of your most important drama (Krista Vernoff’s Rebel) after just five episodes — while keeping The Good Doctor in its same slot behind Dancing with the Stars — is just baffling.
➽ Less is more for Fox. With sports three nights per week, Sunday devoted to animation, and Wednesday smash hit The Masked Singer still a powerhouse, Fox execs basically now just need to worry about programming Monday and Tuesday nights. Their mandate is almost exactly the opposite of the one their streaming counterparts operate under: Instead of rushing to make as much TV as possible, Fox has become almost a boutique broadcaster — aiming for big audiences but with a small scriptedcontent footprint. The downside of this strategy is that it limits the number of chances Fox gets for launching scripted shows, something which in years past would have been a problem: The fewer swings a network takes, the longer the odds of getting a home run. But I don’t think that’s a problem for Fox anymore. It no longer has a huge studio talent roster to support, nor does it have to worry about helping a sister studio build a library of shows to be monetized in syndication. Fox is basically a cable network now, one designed for viewers who want to watch TV rather than binge it. Add in closer coordination with Fox-owned streamer Tubi, and it could be a good formula for success.
The Week’s Other Big News: AT&T Creates Warner-Discovery
Photo-Illustration: by Vulture; Photos by Discovery and HBO
A few days have passed since the Warner–Discovery nuptials were announced, and Hollywood is still trying to figure out what happened and what it all means. On Monday, I wrote about several big questions I had about the newest megacorporation. It will be a while before we know most of the answers, so if you didn’t get a chance to read my analysis, you can check it out here. WarnerMedia went ahead with its preplanned (and pretaped) upfront presentation, which was awkward because a lot of it was built around Jason Kilar touting this amazing new company he had helped shape over the past year. A new message from Kilar, taped after the merger went public, kicked off the presentation, but honestly, that just made everything weirder.
I addressed this in my piece Monday, but I remain stunned at the ruthless efficiency with which AT&T execs screwed over Kilar. He’ll be fine, of course, and no doubt much, much richer. But the corporate killing of Kilar came barely a year after the same phone company geniuses got rid of Bob Greenblatt and Kevin Reilly at HBO Max a mere two months after the streamer debuted. Whatever you think about the justification of the latter sackings, what is undeniable is that AT&T keeps stepping on any sort of momentum HBO Max might be building. And that’s unfortunate because, despite all the drama, Max marks its one-year anniversary next week in damn good shape. It’s grown HBO’s previous subscriber base by about one-third (while charging folks $15 per month). The Flight Attendant and now Hacks will both likely be Emmy contenders. Kilar’s movie strategy has worked, despite the whining from Hollywood’s old guard. And its library of classic movies and TV shows is the best in streaming (though the pre-1990s TV content is woefully lacking). The folks at HBO Max should be celebrating a successful first year instead of worrying whether they’ll have jobs in six months. Moral of the story: Phone companies should stay out of the entertainment business.
Want to Save $5?
Speaking of HBO Max, the streamer also revealed the details of its long-expected ad-supported tier. It will cost $10 per month and include everything on full-price Max, except for those Warner premiere movies. (More details here.) I think WarnerMedia’s strategy here is certainly preferable to the confusing mess over at Peacock, where content varies depending on whether you choose the free or pay service. And if Max only inserts three or four minutes of ads per hour, and none in HBO originals, it could be a pretty sweet deal for some people on tight budgets. But I don’t know that it will spur a ton of new signups. $10 per month is still a lot, and telling folks they have to pay that much and watch ads will be a no-go on principle for many. After all, Hulu has gotten folks used to paying as little as $60 per year — or $5 per month – for streaming TV with ads. Max may have more, but many consumers won’t see it that way. I wonder if AT&T (or next year, Discovery) will find a way to do deals with cable and internet providers to discount HBO Max With Ads even more? Or maybe even offer it for free with certain bundles? I also wouldn’t be surprised to see AT&T, bottom-line driven company that it is, decide to move many of the millions of wireless customers who now get Max for free to the new ad-supported tier. They never miss a chance to make a few more dimes.
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,"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(1),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;
}, {"1":1,"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(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","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();
// ]]