link1918 link1919 link1920 link1921 link1922 link1923 link1924 link1925 link1926 link1927 link1928 link1929 link1930 link1931 link1932 link1933 link1934 link1935 link1936 link1937 link1938 link1939 link1940 link1941 link1942 link1943 link1944 link1945 link1946 link1947 link1948 link1949 link1950 link1951 link1952 link1953 link1954 link1955 link1956 link1957 link1958 link1959 link1960 link1961 link1962 link1963 link1964 link1965 link1966 link1967 link1968 link1969 link1970 link1971 link1972 link1973 link1974 link1975 link1976 link1977 link1978 link1979 link1980 link1981 link1982 link1983 link1984 link1985 link1986 link1987 link1988 link1989 link1990 link1991 link1992 link1993 link1994 link1995 link1996 link1997 link1998 link1999 link2000 link2001 link2002 link2003 link2004 link2005 link2006 link2007 link2008 link2009 link2010 link2011 link2012 link2013 link2014 link2015 link2016 link2017 link2018 link2019 link2020 link2021 link2022 link2023 link2024 link2025 link2026 link2027 link2028 link2029 link2030 link2031 link2032 link2033 link2034 link2035 link2036 link2037 link2038 link2039 link2040 link2041 link2042 link2043 link2044 link2045 link2046 link2047 link2048 link2049 link2050 link2051 link2052 link2053 link2054

[Vue.js] Adsense injecting style tag into my page (in chrome)

when working on a website that is heavily front-end (vue) and thus when using the async version of adsense.

When testing in various browsers I noticed a display issue in chrome where the height of my page was being changed immediately after ads loaded. Hours later I discovered that within show_ads_impl.js it is injecting style=”height: auto !important;” (or similar) into various places in my source code.

I could not find help on this anywhere and am desperate to find a solution - this really impacts the user experience within my project quite negatively.

I asked for help on the adsense support website and did not get a single response.

I was successful at removing the style attribute added by the ads with a delayed callback routine in my javascript - but as you can imagine that caused the page to flicker in a way that is certainly unpleasant.\_ads\_impl.js

Note the link above will not contain the “injection” code unless you download it from chrome.

The code in question in the file above looks like this:

a.o && !c && f && (e.setProperty(“height”, “auto”, “important”),
d && !$v(String(d.minHeight)) && e.setProperty(“min-height”, “0px”, “important”),
d && !aw(String(d.maxHeight)) && e.setProperty(“max-height”, “none”, “important”))) : (Yv(a, 1, l, c, “height”, h, a.B, a.l),

Solution :

For anyone that may stumble on this in the future. Below is how I was able to “solve” the problem in a way that I deemed good enough to move on.

Like I stated above, google Adsense was injecting style=”height: auto !important; min-height: 0px !important;” into my primary page wrapper element on my website.

Below is the code I used to solve the problem - essentially undoing what Adsense does.

// this code listens for a mutation on the main-wrapper element and resets
// the style attribute back to “null”.
// This is necessary because Google Adsense injects style into this main-wrapper
// element changing its height properties. Note: This only occurs in Chrome.
let wrapper = document.getElementById(‘main-wrapper’)
const observer = new MutationObserver(function (mutations, observer) { = ‘’ = ‘’
observer.observe(wrapper, {
attributes: true,
attributeFilter: [‘style’]