rotary encoder issue

Before I say anything, I'm new to computer hardware and software in general.

Right now, Im trying to use both a temperature/humidity sensor and rotary encoder. I got 2 different sources of code in order to read what with of these sensors are reading and they work. But when I try to combine their code, Arduino doesn't seem to update the position of the rotary encoder as quickly.

#include "dht.h"
#define dht_apin A0 // Analog Pin sensor is connected to
#define outputA 6
#define outputB 7
 int counter = 0; 
 int aState;
 int aLastState; 
dht DHT;
 
void setup(){

  pinMode (outputA,INPUT);
   pinMode (outputB,INPUT);
   
   Serial.begin (9600);
   // Reads the initial state of the outputA
   aLastState = digitalRead(outputA);   
  Serial.begin(9600);
  delay(500);//Delay to let system boot
  Serial.println("DHT11 Humidity & temperature Sensor\n\n");
  delay(1000);//Wait before accessing Sensor
 
}//end "setup()"
 
void loop()
{
 
 {
  //Start of Program 

  
 
    DHT.read11(dht_apin);
    
    Serial.print("Current humidity = ");
    Serial.print(DHT.humidity);
    Serial.print("%  ");
    Serial.print("temperature = ");
    Serial.print(DHT.temperature); 
    Serial.println("C  ");
    delay (300);
  }
{ 
   aState = digitalRead(outputA); // Reads the "current" state of the outputA
   // If the previous and the current state of the outputA are different, that means a Pulse has occured
   if (aState != aLastState){     
     // If the outputB state is different to the outputA state, that means the encoder is rotating clockwise
     if (digitalRead(outputB) != aState) { 
       counter ++;
     } else {
       counter --;
     }
     Serial.print("Position: ");
     Serial.println(counter);
     aLastState = aState;
   }
} 
   
}
delay (300);

Your program is spending most of its time sitting in the delay and doing nothing (not reading the encoder). The beginner's guide to millis() shows how to use millis() for non-blocking timing.

It does no good to read the DHT11 more often than about once per second.

The several things at a time tutorial may have information of interest, as well.

pinMode (outputA,INPUT);
pinMode (outputB,INPUT);

That's a very confusing choice of pin names.