Clockwise from left: Books by Nicole Byer, Colin Jost, Andy Greene, Rachel Bloom, and Joe Berkowitz.
Photo-Illustration: Vulture and Publishers
Clockwise from left: Books by Nicole Byer, Colin Jost, Andy Greene, Rachel Bloom, and Joe Berkowitz.
Photo-Illustration: Vulture and Publishers
It’s not like a year could ever be characterized as “funny” — there are far too many moving parts for a through line of the hilariously whimsical or gut-bustingly amusing to ever take hold to a point of overwhelming dominance over time and space. The best-case scenario we can hope for, for a year, is mundane and uneventful … and 2020 was not that. One could go so far as to say that 2020 was a terrible, horrible, very bad, no good year. Not only was it an election year with its requisite nastiness, but it was one where a staggering number of people got sick and died, and another staggering number of people responded to that sickness and death with an emphatic “meh.”
Shutdowns, lockdowns, isolation, and loneliness were a matter of course for many this year, along with the needs to fill free time, practice self-care, and relieve tension. Comedy did its job and provided us poor saps of 2020 with the mirth and day-filling we so desperately needed. This was particularly true for books — books by comedians, books about major comic films and television shows, comic novels, and absurd takes on reality all helped push back the crushing blows of the year with light, laughter, humor, and cleverness. Here then are the ten most notable comedy books of 2020.
10. American Cheese: An Indulgent Odyssey Through the Artisan Cheese World, by Joe Berkowitz
Comedy is really just the intersection point between surprise, revelation, and joy, so it can be found anywhere. One can argue that life is innately a comedy, and so it’s an absolute delight when a true story well told is naturally funny. Joe Berkowitz seeks out these stories by exploring scarcely documented subcultures, such as the world of competitive pun-making in his 2017 book Away With Words and profoundly devoted cheesemaking in his latest, American Cheese. It’s a nutty, chewy, perfectly aged slice-of-life study of the people who make the greatest cheeses in the United States. But why is it so funny? Well, harmless (or even helpful) obsession is always hilarious, but so is cheese itself. It’s a funny word, and the fact that it’s made from weird aged milk is a glitch in the matrix that is life. While he peppers the book with amusing descriptions (e.g., likening fondue pots to jacuzzis, nicknaming the cheese compound tyrosine “flavor crunchies”), Berkowitz serves primarily as a journalist and not joke teller, letting the silliness of situations speak for themselves, like when he attends a massive cheese party literally called the Cheese Ball, and which is hosted by “Madame Fromage.”
9. I Want to Be Where the Normal People Are, by Rachel Bloom
It seems like every famous person eventually gets to write a collection of humorous essays. The best books of this nature are the self-deprecating ones about the individual’s rocky path to success and/or self-actualization, and Rachel Bloom’s is exactly that. Her comic voice lends itself well to this skewed Sedaris format — whether it’s Crazy Ex-Girlfriendor her musical comedy web videos, Bloom’s work is emotionally raw, self-deprecating, and cringe-inducingly relatable, even at its most absurd. We like Rachel Bloom because she gives us permission to admit when we’re clueless. Also, this book boasts the best cover of the year, straight off of the kind of Judy Blume novel that clearly inspired the author’s many endeavors.
8. #VERYFAT #VERYBRAVE: The Fat Girl’s Guide to Being #Brave and Not a Dejected, Melancholy, Down-in-the-Dumps Weeping Fat Girl in a Bikini, by Nicole Byer
Photo: Publisher
I love any piece of entertainment that can take the smallest bit and boldly run with it for the entirety of a work. Richard Ayoade wrote a whole book about the forgettable movie A View From the Top, and the film Mortdecaiis essentially 90 minutes of mustache jokes. It’s admirably ambitious to extend a premise to supernatural heights, repeating and riffing off of the same limited material for so long that it becomes a dazzling comedic feat that manages to simultaneously express that its subject is very meaningful and also not meaningful at all. Nicole Byer, enchanting and charismatic in all of her onscreen performances, pulls this off with #VERYFAT #VERYBRAVE, which is an entire book about overweight people wearing swimsuits, and how they are called courageous for doing so on social media, perhaps patronizingly. And yet, #VERYFAT #VERYBRAVE wildly and boisterously encourages the reader to accept themselves for how they are … and also subtly states that it’s absurd and sad that non-thin people have to even be told to have fun not give a damn what other people think.
7. Alright, Alright, Alright: The Oral History of Richard Linklater’s Dazed and Confused, by Melissa Maerz
Photo: Publisher
It must be tough to assemble an oral history. Authors have to sort through hundreds of hours of interviews with dozens of people, then find the best bits and assemble them in just the right order to tell a story that’s objective and clear while also ensuring that the correct vibe of the subject comes across. And for something like Dazed and Confused, it is all about the vibe. Alright, Alright, Alrightauthentically and viscerally captures what it must have felt like to make the iconic, low-key indie comedy in Austin, Texas, in the early ‘90s, which is set on the last day of school in Austin, Texas, in 1976. In short, when a bunch of future movie stars — including an already transcendent Matthew McConaughey — recreated Linklater’s high-school experience, it was casual, warm, breezy, and loose, with lots of consequence-free substance use. (Or, you know, much like Dazed and Confused.) Alright, Alright, Alright is extremely immersive and like the film it’s about, evokes that magical time of youth when one can instantly forge lifelong friendships all while embarking on wacky, booze-soaked adventures.
6. Build Your Own Romantic Comedy: Pick Your Plot, Meet Your Man, and Direct Your Happily Ever After, by Lana Schwartz
Photo: Publisher
You know what’s fun? Romantic comedies. They’re frothy, earnest, and guarantee a happy ending. Also fun: finding a playful, punchy, high-concept humor title on a bookstore display table and thumbing through it and laughing out loud several times per page. A third fun thing: Choose Your Own Adventure, those adventure tales even reluctant readers read in grade school because we loved starting over when the story didn’t go our way — it gave us control over the story and also subverted tropes. With Build Your Own Romantic Comedy, Lana Schwartz combines all the fun things listed above, deftly subverting the tired formulas utilized by ‘80s, ‘90s, and Hallmark Channel rom-coms (a subject of which she clearly has an encyclopedic knowledge and unabating appreciation) by making those the story points of a rollicking, meta, Choose Your Own Adventure novel for adults whose notions of romance are skewed and cracked from a lifelong diet of Meg Ryan movies. And because of its game-type format, there’s a lot of replay in Build Your Own Romantic Comedy, not unlike a well-liked rom-com.
Mike Sacks, already a pioneer in taking comedy seriously with his insightful comedian interview collections And Here’s the Kicker (2009) and Poking a Dead Frog (2014), has created another unique and fresh contribution to the culture: fake movie novelizations. Novelizations are those cheap paperbacks that told a popcorn movie’s plot in prose form, and they were very popular in the ‘70s and ‘80s as a way to re-live a favorite film in the days before omnipresent home video, cable reruns, and instant streaming. Writing under fake names, Sacks has taken on this very particular book genre to present phony novel version of movies that never technically existed in similarly long-gone film genres, such as his adaptation of a ‘70s trucker movie (2017’s Stinker Lets Loose) and an ’80s teen flick (2019’s Passable in Pink). This year, Sacks turned his attention to skewering early ’90s slacker and grunge culture, a moment heretofore unexamined and rarely mocked. Slouchers nails the sanctimonious, self-indulgent navel gazing of the era and its music and movies (particularly Singles and Slacker) while also teasing those who fell for its insidious marketing. The Slouchers novelization is presented as a used copy, with the ridiculous marginal notes and underlines of the previous owner preserved.
In comedy nerd circles and amongst people who write about comedy, there’s a tenuous tolerance for Colin Jost. Nobody seems to like the guy, nor can many acknowledge it when he turns out a particularly good performance on Saturday Night Live as a “Weekend Update” anchor. He enjoys a reputation as just another Lampoon-trained white guy on the privileged comedy lifer path. Jost knows that’s how he’s perceived — as evidenced by his memoir’s title. But this is a good memoir in that it proves Jost is also not the things we think of him. He’s lived a colorful life, he’s a dutiful student of comedy, and his book is so well-written one realizes that his voice has immensely shaped the tone of SNL for many years. But even if all this wasn’t true, if this was just yet another backstage at Saturday Night Live book, it would make this list because never-before-heard stories and lore from the illustrious comedy institution is irresistible to the same comedy nerds who purport to hate Jost.
3. Little Miss Little Compton: A Memoir, by Arden Myrin
Photo: Publisher
Little Miss Little Compton is a refreshingly original and unpredictable autobiography. The actor’s memoir is her life story, but it reads like a coming-of-age comic novel. Myrin has appeared in dozens of comedy things you’ve liked, and she was among the best cast members on the underrated MADtv, but Little Miss Little Compton primarily deals with her nontraditional, bohemian childhood in Rhode Island and fascinating family, who have a penchant for getting married on dares. That, in turn, informed her pursuit of comedy and acting, which are professions about taking chances, going for it, and making oneself vulnerable, qualities that are abundant in Little Miss Little Compton.
2. Laugh Lines: My Life Helping Funny People Be Funnier, by Alan Zweibel
Photo: Publisher
However inadvertent, if his constant self-effacing humor is to be taken at face value, Alan Zweibel is an architect of 20th century comedy, his influence and experience spanning several distinct eras. His professional memoir begins with his recollections as a gag writer, selling cornball jokes by the piece to vaudeville-vintage Catskills and Borscht Belt comedians. As American humor evolved, so too did Zweibel, and then his book becomes a collection of crackling anecdotes about early Saturday Night Live, where the author wrote for and with the great Gilda Radner … when they weren’t having weekly blowouts about their differences in comedic vision. And then the book takes another turn because Zweibel adapted and looked forward, helping to create It’s Garry Shandling’s Show, the first postmodern sitcom. The throughline in all of Zwiebel’s experiences is also the moral of the story: Comedy is beautiful but also tough, and it comes only through some combination of collaboration and hard work.
1. The Office: The Untold Story of the Greatest Sitcom of the 2000s: An Oral History, by Andy Greene
Photo: Publisher
Sure, a TV show can attain G.O.A.T. status in the hearts and minds of its fans, win Emmys, and attract millions of viewers, but it doesn’t feel like a permanent and essential pillar of popular culture until somebody writes the definitive reference book about it. There are plenty of books out there detailing every bit of landmark comedy programs like SNL, The Simpsons, and Seinfeld, and now, per this logic, the American version of The Office takes its place among the all-time greats because Rolling Stone writer Andy Greene wrote an exhaustive and lovingly researched history. He seemingly answers every question anybody could ever have about The Office by interviewing dozens of cast members, writers, and crew members. The result is hundreds of fun facts and scandalous stories nobody ever knew about The Office before, and which help bring the comedy far out of the shadow of its British predecessor. The Office is so embedded into the consciousness at this point — reruns air everywhere, and it’s one of the most popular streaming titles ever — and Greene reminds readers just why they fell in love with this show in the first place, convincingly arguing for its spot in the annals of TV history, and in the process, crafting a vital, info-packed addition for the comedy nerd’s library.
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();
// ]]